{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Requirement already satisfied: backtrader[plotting] in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (1.9.74.123)\r\n",
      "Requirement already satisfied: matplotlib; extra == \"plotting\" in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from backtrader[plotting]) (3.0.2)\r\n",
      "Requirement already satisfied: numpy>=1.10.0 in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from matplotlib; extra == \"plotting\"->backtrader[plotting]) (1.15.4)\r\n",
      "Requirement already satisfied: cycler>=0.10 in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from matplotlib; extra == \"plotting\"->backtrader[plotting]) (0.10.0)\r\n",
      "Requirement already satisfied: kiwisolver>=1.0.1 in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from matplotlib; extra == \"plotting\"->backtrader[plotting]) (1.0.1)\r\n",
      "Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from matplotlib; extra == \"plotting\"->backtrader[plotting]) (2.3.0)\r\n",
      "Requirement already satisfied: python-dateutil>=2.1 in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from matplotlib; extra == \"plotting\"->backtrader[plotting]) (2.7.5)\r\n",
      "Requirement already satisfied: six in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from cycler>=0.10->matplotlib; extra == \"plotting\"->backtrader[plotting]) (1.12.0)\r\n",
      "Requirement already satisfied: setuptools in /Users/enzoampil/anaconda3/lib/python3.7/site-packages (from kiwisolver>=1.0.1->matplotlib; extra == \"plotting\"->backtrader[plotting]) (40.6.3)\r\n"
     ]
    }
   ],
   "source": [
    "#!pip install backtrader[plotting]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Starting Portfolio Value: 100000.00\n",
      "2017-01-03, Cash 100000.0 Value 100000.0\n",
      "2017-01-04, Cash 100000.0 Value 100000.0\n",
      "2017-01-05, Cash 100000.0 Value 100000.0\n",
      "2017-01-06, Cash 100000.0 Value 100000.0\n",
      "2017-01-09, Cash 100000.0 Value 100000.0\n",
      "2017-01-10, Cash 100000.0 Value 100000.0\n",
      "2017-01-11, Cash 100000.0 Value 100000.0\n",
      "2017-01-12, Cash 100000.0 Value 100000.0\n",
      "2017-01-13, Cash 100000.0 Value 100000.0\n",
      "2017-01-16, Cash 100000.0 Value 100000.0\n",
      "2017-01-17, Cash 100000.0 Value 100000.0\n",
      "2017-01-18, Cash 100000.0 Value 100000.0\n",
      "2017-01-19, Cash 100000.0 Value 100000.0\n",
      "2017-01-20, Cash 100000.0 Value 100000.0\n",
      "2017-01-23, Cash 100000.0 Value 100000.0\n",
      "2017-01-23, Close, 207.00\n",
      "rsi: 57.57575757575758\n",
      "2017-01-24, Cash 100000.0 Value 100000.0\n",
      "2017-01-24, Close, 206.00\n",
      "rsi: 56.26423690205011\n",
      "2017-01-25, Cash 100000.0 Value 100000.0\n",
      "2017-01-25, Close, 207.20\n",
      "rsi: 57.51489361702126\n",
      "2017-01-26, Cash 100000.0 Value 100000.0\n",
      "2017-01-26, Close, 207.00\n",
      "rsi: 57.221201818489725\n",
      "2017-01-27, Cash 100000.0 Value 100000.0\n",
      "2017-01-27, Close, 208.00\n",
      "rsi: 58.36596252624558\n",
      "2017-01-30, Cash 100000.0 Value 100000.0\n",
      "2017-01-30, Close, 209.00\n",
      "rsi: 59.53218282864497\n",
      "2017-01-31, Cash 100000.0 Value 100000.0\n",
      "2017-01-31, Close, 205.60\n",
      "rsi: 53.99430206010131\n",
      "2017-02-01, Cash 100000.0 Value 100000.0\n",
      "2017-02-01, Close, 207.00\n",
      "rsi: 55.81686334368651\n",
      "2017-02-02, Cash 100000.0 Value 100000.0\n",
      "2017-02-02, Close, 206.40\n",
      "rsi: 54.814616278869345\n",
      "2017-02-03, Cash 100000.0 Value 100000.0\n",
      "2017-02-03, Close, 206.00\n",
      "rsi: 54.11696844524332\n",
      "2017-02-06, Cash 100000.0 Value 100000.0\n",
      "2017-02-06, Close, 208.00\n",
      "rsi: 57.05975699324669\n",
      "2017-02-07, Cash 100000.0 Value 100000.0\n",
      "2017-02-07, Close, 206.60\n",
      "rsi: 54.42819498418347\n",
      "2017-02-08, Cash 100000.0 Value 100000.0\n",
      "2017-02-08, Close, 206.00\n",
      "rsi: 53.29378982441762\n",
      "2017-02-09, Cash 100000.0 Value 100000.0\n",
      "2017-02-09, Close, 206.00\n",
      "rsi: 53.29378982441762\n",
      "2017-02-10, Cash 100000.0 Value 100000.0\n",
      "2017-02-10, Close, 206.00\n",
      "rsi: 53.29378982441762\n",
      "2017-02-13, Cash 100000.0 Value 100000.0\n",
      "2017-02-13, Close, 207.00\n",
      "rsi: 55.235913091509744\n",
      "2017-02-14, Cash 100000.0 Value 100000.0\n",
      "2017-02-14, Close, 206.00\n",
      "rsi: 52.868448924592876\n",
      "2017-02-15, Cash 100000.0 Value 100000.0\n",
      "2017-02-15, Close, 201.40\n",
      "rsi: 43.6090812610354\n",
      "2017-02-16, Cash 100000.0 Value 100000.0\n",
      "2017-02-16, Close, 206.00\n",
      "rsi: 52.557338977765546\n",
      "2017-02-17, Cash 100000.0 Value 100000.0\n",
      "2017-02-17, Close, 205.00\n",
      "rsi: 50.674782315291274\n",
      "2017-02-20, Cash 100000.0 Value 100000.0\n",
      "2017-02-20, Close, 205.00\n",
      "rsi: 50.674782315291274\n",
      "2017-02-21, Cash 100000.0 Value 100000.0\n",
      "2017-02-21, Close, 206.00\n",
      "rsi: 52.64210867797726\n",
      "2017-02-22, Cash 100000.0 Value 100000.0\n",
      "2017-02-22, Close, 201.80\n",
      "rsi: 44.596762950484504\n",
      "2017-02-23, Cash 100000.0 Value 100000.0\n",
      "2017-02-23, Close, 203.00\n",
      "rsi: 47.085082745282975\n",
      "2017-02-24, Cash 100000.0 Value 100000.0\n",
      "2017-02-24, Close, 201.80\n",
      "rsi: 44.91275459606706\n",
      "2017-02-27, Cash 100000.0 Value 100000.0\n",
      "2017-02-27, Close, 203.00\n",
      "rsi: 47.52022129354347\n",
      "2017-02-28, Cash 100000.0 Value 100000.0\n",
      "2017-02-28, Close, 201.80\n",
      "rsi: 45.21539233994006\n",
      "2017-03-01, Cash 100000.0 Value 100000.0\n",
      "2017-03-01, Close, 202.80\n",
      "rsi: 47.50056143981531\n",
      "2017-03-02, Cash 100000.0 Value 100000.0\n",
      "2017-03-02, Close, 203.40\n",
      "rsi: 48.8784056348595\n",
      "2017-03-03, Cash 100000.0 Value 100000.0\n",
      "2017-03-03, Close, 201.00\n",
      "rsi: 43.913734369217664\n",
      "2017-03-06, Cash 100000.0 Value 100000.0\n",
      "2017-03-06, Close, 198.00\n",
      "rsi: 38.631584880213715\n",
      "2017-03-07, Cash 100000.0 Value 100000.0\n",
      "2017-03-07, Close, 194.90\n",
      "rsi: 34.07100206269672\n",
      "2017-03-08, Cash 100000.0 Value 100000.0\n",
      "2017-03-08, Close, 193.80\n",
      "rsi: 32.60033113579705\n",
      "2017-03-09, Cash 100000.0 Value 100000.0\n",
      "2017-03-09, Close, 197.10\n",
      "rsi: 40.84924603430075\n",
      "2017-03-10, Cash 100000.0 Value 100000.0\n",
      "2017-03-10, Close, 194.00\n",
      "rsi: 36.348744515817366\n",
      "2017-03-13, Cash 100000.0 Value 100000.0\n",
      "2017-03-13, Close, 196.80\n",
      "rsi: 42.50975628133897\n",
      "2017-03-14, Cash 100000.0 Value 100000.0\n",
      "2017-03-14, Close, 197.00\n",
      "rsi: 42.93464406261318\n",
      "2017-03-15, Cash 100000.0 Value 100000.0\n",
      "2017-03-15, Close, 196.00\n",
      "rsi: 41.291427960092314\n",
      "2017-03-16, Cash 100000.0 Value 100000.0\n",
      "2017-03-16, Close, 196.00\n",
      "rsi: 41.29142796009232\n",
      "2017-03-17, Cash 100000.0 Value 100000.0\n",
      "2017-03-17, Close, 193.20\n",
      "rsi: 36.72687556225484\n",
      "2017-03-20, Cash 100000.0 Value 100000.0\n",
      "2017-03-20, Close, 192.80\n",
      "rsi: 36.11271061521475\n",
      "2017-03-21, Cash 100000.0 Value 100000.0\n",
      "2017-03-21, Close, 194.00\n",
      "rsi: 39.38739844066971\n",
      "2017-03-22, Cash 100000.0 Value 100000.0\n",
      "2017-03-22, Close, 191.00\n",
      "rsi: 34.6110605520616\n",
      "2017-03-23, Cash 100000.0 Value 100000.0\n",
      "2017-03-23, Close, 190.20\n",
      "rsi: 33.44629329076908\n",
      "2017-03-24, Cash 100000.0 Value 100000.0\n",
      "2017-03-24, Close, 188.00\n",
      "rsi: 30.414990556714756\n",
      "2017-03-27, Cash 100000.0 Value 100000.0\n",
      "2017-03-27, Close, 182.10\n",
      "rsi: 24.105302169457104\n",
      "2017-03-27, BUY CREATE, 182.10\n",
      "2017-03-28, BUY EXECUTED, Price: 184.00, Cost: 9936.00, Comm 59.62\n",
      "2017-03-28, Cash 90004.384 Value 99859.384\n",
      "2017-03-28, Close, 182.50\n",
      "rsi: 25.237691045051733\n",
      "2017-03-28, BUY CREATE, 182.50\n",
      "2017-03-29, BUY EXECUTED, Price: 183.10, Cost: 9887.40, Comm 59.32\n",
      "2017-03-29, Cash 80057.65960000001 Value 100361.65960000001\n",
      "2017-03-29, Close, 188.00\n",
      "rsi: 38.76652702669176\n",
      "2017-03-30, Cash 80057.65960000001 Value 101063.65960000001\n",
      "2017-03-30, Close, 194.50\n",
      "rsi: 50.22923852301827\n",
      "2017-03-31, Cash 80057.65960000001 Value 101387.65960000001\n",
      "2017-03-31, Close, 197.50\n",
      "rsi: 54.46593609636357\n",
      "2017-04-03, Cash 80057.65960000001 Value 101333.65960000001\n",
      "2017-04-03, Close, 197.00\n",
      "rsi: 53.646290130569014\n",
      "2017-04-04, Cash 80057.65960000001 Value 101441.65960000001\n",
      "2017-04-04, Close, 198.00\n",
      "rsi: 55.10157209538342\n",
      "2017-04-05, Cash 80057.65960000001 Value 101463.25960000002\n",
      "2017-04-05, Close, 198.20\n",
      "rsi: 55.40313758006725\n",
      "2017-04-06, Cash 80057.65960000001 Value 101657.65960000001\n",
      "2017-04-06, Close, 200.00\n",
      "rsi: 58.12892393820978\n",
      "2017-04-07, Cash 80057.65960000001 Value 102780.85960000001\n",
      "2017-04-07, Close, 210.40\n",
      "rsi: 69.66536399831395\n",
      "2017-04-10, Cash 80057.65960000001 Value 102586.45960000002\n",
      "2017-04-10, Close, 208.60\n",
      "rsi: 66.2624644793492\n",
      "2017-04-11, Cash 80057.65960000001 Value 102478.45960000002\n",
      "2017-04-11, Close, 207.60\n",
      "rsi: 64.38097437587349\n",
      "2017-04-12, Cash 80057.65960000001 Value 102608.05960000001\n",
      "2017-04-12, Close, 208.80\n",
      "rsi: 65.64173184064202\n",
      "2017-04-17, Cash 80057.65960000001 Value 102629.65960000001\n",
      "2017-04-17, Close, 209.00\n",
      "rsi: 65.85863398210353\n",
      "2017-04-18, Cash 80057.65960000001 Value 102413.65960000001\n",
      "2017-04-18, Close, 207.00\n",
      "rsi: 61.66621615423943\n",
      "2017-04-19, Cash 80057.65960000001 Value 102024.85960000001\n",
      "2017-04-19, Close, 203.40\n",
      "rsi: 54.89256878500411\n",
      "2017-04-20, Cash 80057.65960000001 Value 102197.65960000001\n",
      "2017-04-20, Close, 205.00\n",
      "rsi: 57.145627888771685\n",
      "2017-04-21, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-04-21, Close, 208.00\n",
      "rsi: 61.07184462089354\n",
      "2017-04-24, Cash 80057.65960000001 Value 102780.85960000001\n",
      "2017-04-24, Close, 210.40\n",
      "rsi: 63.91973654238581\n",
      "2017-04-25, Cash 80057.65960000001 Value 103169.65960000001\n",
      "2017-04-25, Close, 214.00\n",
      "rsi: 67.73297957189672\n",
      "2017-04-26, Cash 80057.65960000001 Value 103169.65960000001\n",
      "2017-04-26, Close, 214.00\n",
      "rsi: 67.73297957189672\n",
      "2017-04-27, Cash 80057.65960000001 Value 102737.65960000001\n",
      "2017-04-27, Close, 210.00\n",
      "rsi: 59.61402539096893\n",
      "2017-05-02, Cash 80057.65960000001 Value 103364.05960000001\n",
      "2017-05-02, Close, 215.80\n",
      "rsi: 65.98150659102396\n",
      "2017-05-03, Cash 80057.65960000001 Value 103083.25960000002\n",
      "2017-05-03, Close, 213.20\n",
      "rsi: 61.31458070557425\n",
      "2017-05-04, Cash 80057.65960000001 Value 103104.85960000001\n",
      "2017-05-04, Close, 213.40\n",
      "rsi: 61.53993199897091\n",
      "2017-05-05, Cash 80057.65960000001 Value 103385.65960000001\n",
      "2017-05-05, Close, 216.00\n",
      "rsi: 64.43996513657225\n",
      "2017-05-08, Cash 80057.65960000001 Value 103666.45960000002\n",
      "2017-05-08, Close, 218.60\n",
      "rsi: 67.11070825080859\n",
      "2017-05-09, Cash 80057.65960000001 Value 103709.65960000001\n",
      "2017-05-09, Close, 219.00\n",
      "rsi: 67.51493496054147\n",
      "2017-05-10, Cash 80057.65960000001 Value 102845.65960000001\n",
      "2017-05-10, Close, 211.00\n",
      "rsi: 53.383347058478726\n",
      "2017-05-11, Cash 80057.65960000001 Value 103061.65960000001\n",
      "2017-05-11, Close, 213.00\n",
      "rsi: 55.8701873025069\n",
      "2017-05-12, Cash 80057.65960000001 Value 102953.65960000001\n",
      "2017-05-12, Close, 212.00\n",
      "rsi: 54.3101237912617\n",
      "2017-05-15, Cash 80057.65960000001 Value 102305.65960000001\n",
      "2017-05-15, Close, 206.00\n",
      "rsi: 46.008935403912126\n",
      "2017-05-16, Cash 80057.65960000001 Value 102197.65960000001\n",
      "2017-05-16, Close, 205.00\n",
      "rsi: 44.78041871591914\n",
      "2017-05-17, Cash 80057.65960000001 Value 102197.65960000001\n",
      "2017-05-17, Close, 205.00\n",
      "rsi: 44.78041871591914\n",
      "2017-05-18, Cash 80057.65960000001 Value 101657.65960000001\n",
      "2017-05-18, Close, 200.00\n",
      "rsi: 38.776355749596824\n",
      "2017-05-19, Cash 80057.65960000001 Value 101981.65960000001\n",
      "2017-05-19, Close, 203.00\n",
      "rsi: 43.65757750015675\n",
      "2017-05-22, Cash 80057.65960000001 Value 101895.25960000002\n",
      "2017-05-22, Close, 202.20\n",
      "rsi: 42.68036084728746\n",
      "2017-05-23, Cash 80057.65960000001 Value 101765.65960000001\n",
      "2017-05-23, Close, 201.00\n",
      "rsi: 41.19096832332321\n",
      "2017-05-24, Cash 80057.65960000001 Value 102327.25960000002\n",
      "2017-05-24, Close, 206.20\n",
      "rsi: 49.426813703752444\n",
      "2017-05-25, Cash 80057.65960000001 Value 102413.65960000001\n",
      "2017-05-25, Close, 207.00\n",
      "rsi: 50.573630885311864\n",
      "2017-05-26, Cash 80057.65960000001 Value 101808.85960000001\n",
      "2017-05-26, Close, 201.40\n",
      "rsi: 43.19043812373672\n",
      "2017-05-29, Cash 80057.65960000001 Value 101981.65960000001\n",
      "2017-05-29, Close, 203.00\n",
      "rsi: 45.63260445971936\n",
      "2017-05-30, Cash 80057.65960000001 Value 102068.05960000001\n",
      "2017-05-30, Close, 203.80\n",
      "rsi: 46.862614538324735\n",
      "2017-05-31, Cash 80057.65960000001 Value 102154.45960000002\n",
      "2017-05-31, Close, 204.60\n",
      "rsi: 48.12647914189962\n",
      "2017-06-01, Cash 80057.65960000001 Value 103385.65960000001\n",
      "2017-06-01, Close, 216.00\n",
      "rsi: 61.997585632379646\n",
      "2017-06-02, Cash 80057.65960000001 Value 103169.65960000001\n",
      "2017-06-02, Close, 214.00\n",
      "rsi: 59.01601509100391\n",
      "2017-06-05, Cash 80057.65960000001 Value 103385.65960000001\n",
      "2017-06-05, Close, 216.00\n",
      "rsi: 61.03410120129326\n",
      "2017-06-06, Cash 80057.65960000001 Value 103256.05960000001\n",
      "2017-06-06, Close, 214.80\n",
      "rsi: 59.15205079711999\n",
      "2017-06-07, Cash 80057.65960000001 Value 103450.45960000002\n",
      "2017-06-07, Close, 216.60\n",
      "rsi: 61.090227337777165\n",
      "2017-06-08, Cash 80057.65960000001 Value 103364.05960000001\n",
      "2017-06-08, Close, 215.80\n",
      "rsi: 59.733650807089056\n",
      "2017-06-09, Cash 80057.65960000001 Value 103364.05960000001\n",
      "2017-06-09, Close, 215.80\n",
      "rsi: 59.733650807089056\n",
      "2017-06-13, Cash 80057.65960000001 Value 103191.25960000002\n",
      "2017-06-13, Close, 214.20\n",
      "rsi: 56.80762243064597\n",
      "2017-06-14, Cash 80057.65960000001 Value 103320.85960000001\n",
      "2017-06-14, Close, 215.40\n",
      "rsi: 58.451468327358725\n",
      "2017-06-15, Cash 80057.65960000001 Value 103299.25960000002\n",
      "2017-06-15, Close, 215.20\n",
      "rsi: 58.05489249068077\n",
      "2017-06-16, Cash 80057.65960000001 Value 103493.65960000001\n",
      "2017-06-16, Close, 217.00\n",
      "rsi: 60.642987086679206\n",
      "2017-06-19, Cash 80057.65960000001 Value 103385.65960000001\n",
      "2017-06-19, Close, 216.00\n",
      "rsi: 58.4840094157586\n",
      "2017-06-20, Cash 80057.65960000001 Value 103277.65960000001\n",
      "2017-06-20, Close, 215.00\n",
      "rsi: 56.324526376523245\n",
      "2017-06-21, Cash 80057.65960000001 Value 103320.85960000001\n",
      "2017-06-21, Close, 215.40\n",
      "rsi: 57.008345888550615\n",
      "2017-06-22, Cash 80057.65960000001 Value 103040.05960000001\n",
      "2017-06-22, Close, 212.80\n",
      "rsi: 51.37748560174935\n",
      "2017-06-23, Cash 80057.65960000001 Value 102845.65960000001\n",
      "2017-06-23, Close, 211.00\n",
      "rsi: 47.85350200705799\n",
      "2017-06-27, Cash 80057.65960000001 Value 102737.65960000001\n",
      "2017-06-27, Close, 210.00\n",
      "rsi: 45.967158137948374\n",
      "2017-06-28, Cash 80057.65960000001 Value 102586.45960000002\n",
      "2017-06-28, Close, 208.60\n",
      "rsi: 43.388495939760276\n",
      "2017-06-29, Cash 80057.65960000001 Value 102240.85960000001\n",
      "2017-06-29, Close, 205.40\n",
      "rsi: 38.12405228914134\n",
      "2017-06-30, Cash 80057.65960000001 Value 102089.65960000001\n",
      "2017-06-30, Close, 204.00\n",
      "rsi: 36.06249055980047\n",
      "2017-07-03, Cash 80057.65960000001 Value 102327.25960000002\n",
      "2017-07-03, Close, 206.20\n",
      "rsi: 41.42297371873391\n",
      "2017-07-04, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-07-04, Close, 208.00\n",
      "rsi: 45.45253098944995\n",
      "2017-07-05, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-07-05, Close, 208.00\n",
      "rsi: 45.45253098944994\n",
      "2017-07-06, Cash 80057.65960000001 Value 102435.25960000002\n",
      "2017-07-06, Close, 207.20\n",
      "rsi: 43.89605525430096\n",
      "2017-07-07, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-07-07, Close, 208.00\n",
      "rsi: 45.89147675527785\n",
      "2017-07-10, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-07-10, Close, 208.00\n",
      "rsi: 45.89147675527785\n",
      "2017-07-11, Cash 80057.65960000001 Value 102521.65960000001\n",
      "2017-07-11, Close, 208.00\n",
      "rsi: 45.89147675527785\n",
      "2017-07-12, Cash 80057.65960000001 Value 102953.65960000001\n",
      "2017-07-12, Close, 212.00\n",
      "rsi: 55.72527281947281\n",
      "2017-07-13, Cash 80057.65960000001 Value 103234.45960000002\n",
      "2017-07-13, Close, 214.60\n",
      "rsi: 60.722176423788056\n",
      "2017-07-14, Cash 80057.65960000001 Value 103277.65960000001\n",
      "2017-07-14, Close, 215.00\n",
      "rsi: 61.443147722288614\n",
      "2017-07-17, Cash 80057.65960000001 Value 103299.25960000002\n",
      "2017-07-17, Close, 215.20\n",
      "rsi: 61.82050732144875\n",
      "2017-07-18, Cash 80057.65960000001 Value 103493.65960000001\n",
      "2017-07-18, Close, 217.00\n",
      "rsi: 65.12841034302386\n",
      "2017-07-19, Cash 80057.65960000001 Value 103860.85960000001\n",
      "2017-07-19, Close, 220.40\n",
      "rsi: 70.35343241885704\n",
      "2017-07-19, SELL CREATE, 220.40\n",
      "2017-07-20, SELL EXECUTED, Price: 220.40, Cost: 8259.75, Comm 59.51\n",
      "2017-07-20, Cash 89916.15160000001 Value 103776.15160000001\n",
      "2017-07-20, Close, 220.00\n",
      "rsi: 69.04274185823633\n",
      "2017-07-21, Cash 89916.15160000001 Value 103889.5516\n",
      "2017-07-21, Close, 221.80\n",
      "rsi: 71.60625071017758\n",
      "2017-07-21, SELL CREATE, 221.80\n",
      "2017-07-24, SELL EXECUTED, Price: 221.80, Cost: 8259.75, Comm 59.89\n",
      "2017-07-24, Cash 99837.26560000001 Value 103782.86560000002\n",
      "2017-07-24, Close, 219.20\n",
      "rsi: 63.43502887674214\n",
      "2017-07-25, Cash 99837.26560000001 Value 103757.66560000001\n",
      "2017-07-25, Close, 217.80\n",
      "rsi: 59.49792173667657\n",
      "2017-07-26, Cash 99837.26560000001 Value 103739.66560000001\n",
      "2017-07-26, Close, 216.80\n",
      "rsi: 56.78678143123152\n",
      "2017-07-27, Cash 99837.26560000001 Value 103779.26560000001\n",
      "2017-07-27, Close, 219.00\n",
      "rsi: 60.997445672379264\n",
      "2017-07-28, Cash 99837.26560000001 Value 103833.26560000001\n",
      "2017-07-28, Close, 222.00\n",
      "rsi: 65.87979536759606\n",
      "2017-07-31, Cash 99837.26560000001 Value 103887.26560000001\n",
      "2017-07-31, Close, 225.00\n",
      "rsi: 69.93309936912465\n",
      "2017-08-01, Cash 99837.26560000001 Value 103851.26560000001\n",
      "2017-08-01, Close, 223.00\n",
      "rsi: 64.4373298566407\n",
      "2017-08-02, Cash 99837.26560000001 Value 103761.26560000001\n",
      "2017-08-02, Close, 218.00\n",
      "rsi: 53.184633559888745\n",
      "2017-08-03, Cash 99837.26560000001 Value 103725.26560000001\n",
      "2017-08-03, Close, 216.00\n",
      "rsi: 49.46371258564475\n",
      "2017-08-04, Cash 99837.26560000001 Value 103710.86560000002\n",
      "2017-08-04, Close, 215.20\n",
      "rsi: 48.01660635875893\n",
      "2017-08-07, Cash 99837.26560000001 Value 103779.26560000001\n",
      "2017-08-07, Close, 219.00\n",
      "rsi: 54.783494407788545\n",
      "2017-08-08, Cash 99837.26560000001 Value 103779.26560000001\n",
      "2017-08-08, Close, 219.00\n",
      "rsi: 54.783494407788545\n",
      "2017-08-09, Cash 99837.26560000001 Value 103743.26560000001\n",
      "2017-08-09, Close, 217.00\n",
      "rsi: 50.75090572935674\n",
      "2017-08-10, Cash 99837.26560000001 Value 103743.26560000001\n",
      "2017-08-10, Close, 217.00\n",
      "rsi: 50.75090572935675\n",
      "2017-08-11, Cash 99837.26560000001 Value 103732.46560000001\n",
      "2017-08-11, Close, 216.40\n",
      "rsi: 49.48358660837363\n",
      "2017-08-14, Cash 99837.26560000001 Value 103833.26560000001\n",
      "2017-08-14, Close, 222.00\n",
      "rsi: 59.61898606232501\n",
      "2017-08-15, Cash 99837.26560000001 Value 103887.26560000001\n",
      "2017-08-15, Close, 225.00\n",
      "rsi: 63.80823385274172\n",
      "2017-08-16, Cash 99837.26560000001 Value 104139.26560000001\n",
      "2017-08-16, Close, 239.00\n",
      "rsi: 76.21114876792821\n",
      "2017-08-16, SELL CREATE, 239.00\n",
      "2017-08-17, SELL EXECUTED, Price: 238.00, Cost: -2170.10, Comm 58.55\n",
      "2017-08-17, OPERATION PROFIT, GROSS 4359.60, NET 4095.56\n",
      "2017-08-17, Cash 109536.71760000002 Value 104058.11760000001\n",
      "2017-08-17, Close, 238.20\n",
      "rsi: 74.63710995642552\n",
      "2017-08-18, Cash 109536.71760000002 Value 104127.11760000001\n",
      "2017-08-18, Close, 235.20\n",
      "rsi: 68.89098245905757\n",
      "2017-08-22, Cash 109536.71760000002 Value 104016.71760000002\n",
      "2017-08-22, Close, 240.00\n",
      "rsi: 72.53443892581973\n",
      "2017-08-23, Cash 109536.71760000002 Value 104035.11760000001\n",
      "2017-08-23, Close, 239.20\n",
      "rsi: 71.04105954027011\n",
      "2017-08-24, Cash 109536.71760000002 Value 104016.71760000002\n",
      "2017-08-24, Close, 240.00\n",
      "rsi: 71.6692178991394\n",
      "2017-08-25, Cash 109536.71760000002 Value 104039.71760000002\n",
      "2017-08-25, Close, 239.00\n",
      "rsi: 69.63585869010035\n",
      "2017-08-29, Cash 109536.71760000002 Value 104044.31760000002\n",
      "2017-08-29, Close, 238.80\n",
      "rsi: 69.21291431152072\n",
      "2017-08-30, Cash 109536.71760000002 Value 104044.31760000002\n",
      "2017-08-30, Close, 238.80\n",
      "rsi: 69.21291431152072\n",
      "2017-08-31, Cash 109536.71760000002 Value 104058.11760000001\n",
      "2017-08-31, Close, 238.20\n",
      "rsi: 67.78057409447446\n",
      "2017-09-04, Cash 109536.71760000002 Value 104062.71760000002\n",
      "2017-09-04, Close, 238.00\n",
      "rsi: 67.28075443848905\n",
      "2017-09-05, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-09-05, Close, 244.00\n",
      "rsi: 73.57599896503143\n",
      "2017-09-06, Cash 109536.71760000002 Value 103993.71760000002\n",
      "2017-09-06, Close, 241.00\n",
      "rsi: 66.66902074192276\n",
      "2017-09-07, Cash 109536.71760000002 Value 103887.91760000002\n",
      "2017-09-07, Close, 245.60\n",
      "rsi: 71.14237921487897\n",
      "2017-09-08, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-09-08, Close, 244.00\n",
      "rsi: 67.73705270730707\n",
      "2017-09-11, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-09-11, Close, 244.00\n",
      "rsi: 67.73705270730707\n",
      "2017-09-13, Cash 109536.71760000002 Value 103970.71760000002\n",
      "2017-09-13, Close, 242.00\n",
      "rsi: 63.34164569919797\n",
      "2017-09-14, Cash 109536.71760000002 Value 103901.71760000002\n",
      "2017-09-14, Close, 245.00\n",
      "rsi: 66.81964703257506\n",
      "2017-09-15, Cash 109536.71760000002 Value 103947.71760000002\n",
      "2017-09-15, Close, 243.00\n",
      "rsi: 62.5584080381011\n",
      "2017-09-18, Cash 109536.71760000002 Value 103901.71760000002\n",
      "2017-09-18, Close, 245.00\n",
      "rsi: 64.96456478418617\n",
      "2017-09-19, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-09-19, Close, 244.00\n",
      "rsi: 62.791729803223575\n",
      "2017-09-20, Cash 109536.71760000002 Value 103970.71760000002\n",
      "2017-09-20, Close, 242.00\n",
      "rsi: 58.5722691670441\n",
      "2017-09-21, Cash 109536.71760000002 Value 103878.71760000002\n",
      "2017-09-21, Close, 246.00\n",
      "rsi: 63.81015359153102\n",
      "2017-09-22, Cash 109536.71760000002 Value 103906.31760000002\n",
      "2017-09-22, Close, 244.80\n",
      "rsi: 61.30592952362505\n",
      "2017-09-25, Cash 109536.71760000002 Value 103901.71760000002\n",
      "2017-09-25, Close, 245.00\n",
      "rsi: 61.57658250655025\n",
      "2017-09-26, Cash 109536.71760000002 Value 103791.31760000002\n",
      "2017-09-26, Close, 249.80\n",
      "rsi: 67.45945169063533\n",
      "2017-09-27, Cash 109536.71760000002 Value 103814.31760000002\n",
      "2017-09-27, Close, 248.80\n",
      "rsi: 65.21912369132791\n",
      "2017-09-28, Cash 109536.71760000002 Value 103970.71760000002\n",
      "2017-09-28, Close, 242.00\n",
      "rsi: 52.46071284063039\n",
      "2017-09-29, Cash 109536.71760000002 Value 103929.31760000002\n",
      "2017-09-29, Close, 243.80\n",
      "rsi: 54.971760016322854\n",
      "2017-10-02, Cash 109536.71760000002 Value 103956.91760000002\n",
      "2017-10-02, Close, 242.60\n",
      "rsi: 52.9632666818234\n",
      "2017-10-03, Cash 109536.71760000002 Value 103970.71760000002\n",
      "2017-10-03, Close, 242.00\n",
      "rsi: 51.941388802177194\n",
      "2017-10-04, Cash 109536.71760000002 Value 103961.51760000002\n",
      "2017-10-04, Close, 242.40\n",
      "rsi: 52.598009006838964\n",
      "2017-10-05, Cash 109536.71760000002 Value 103975.31760000002\n",
      "2017-10-05, Close, 241.80\n",
      "rsi: 51.46219486131442\n",
      "2017-10-06, Cash 109536.71760000002 Value 103966.11760000001\n",
      "2017-10-06, Close, 242.20\n",
      "rsi: 52.20321511192611\n",
      "2017-10-09, Cash 109536.71760000002 Value 103883.31760000002\n",
      "2017-10-09, Close, 245.80\n",
      "rsi: 58.36412468976486\n",
      "2017-10-10, Cash 109536.71760000002 Value 103901.71760000002\n",
      "2017-10-10, Close, 245.00\n",
      "rsi: 56.617619324049436\n",
      "2017-10-11, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-10-11, Close, 244.00\n",
      "rsi: 54.4252239901779\n",
      "2017-10-12, Cash 109536.71760000002 Value 103910.91760000002\n",
      "2017-10-12, Close, 244.60\n",
      "rsi: 55.53771116852619\n",
      "2017-10-13, Cash 109536.71760000002 Value 103855.71760000002\n",
      "2017-10-13, Close, 247.00\n",
      "rsi: 59.768147617258734\n",
      "2017-10-17, Cash 109536.71760000002 Value 103901.71760000002\n",
      "2017-10-17, Close, 245.00\n",
      "rsi: 55.06615891974155\n",
      "2017-10-18, Cash 109536.71760000002 Value 103878.71760000002\n",
      "2017-10-18, Close, 246.00\n",
      "rsi: 56.89224755119221\n",
      "2017-10-19, Cash 109536.71760000002 Value 103855.71760000002\n",
      "2017-10-19, Close, 247.00\n",
      "rsi: 58.69977702418459\n",
      "2017-10-20, Cash 109536.71760000002 Value 103878.71760000002\n",
      "2017-10-20, Close, 246.00\n",
      "rsi: 56.16365551399846\n",
      "2017-10-23, Cash 109536.71760000002 Value 103809.71760000002\n",
      "2017-10-23, Close, 249.00\n",
      "rsi: 61.53307153095165\n",
      "2017-10-24, Cash 109536.71760000002 Value 103832.71760000002\n",
      "2017-10-24, Close, 248.00\n",
      "rsi: 58.94141920332376\n",
      "2017-10-25, Cash 109536.71760000002 Value 103786.71760000002\n",
      "2017-10-25, Close, 250.00\n",
      "rsi: 62.35629697420406\n",
      "2017-10-26, Cash 109536.71760000002 Value 103786.71760000002\n",
      "2017-10-26, Close, 250.00\n",
      "rsi: 62.35629697420406\n",
      "2017-10-27, Cash 109536.71760000002 Value 103791.31760000002\n",
      "2017-10-27, Close, 249.80\n",
      "rsi: 61.76056371384747\n",
      "2017-10-30, Cash 109536.71760000002 Value 103809.71760000002\n",
      "2017-10-30, Close, 249.00\n",
      "rsi: 59.31931334990957\n",
      "2017-11-02, Cash 109536.71760000002 Value 103754.51760000002\n",
      "2017-11-02, Close, 251.40\n",
      "rsi: 63.92611886164371\n",
      "2017-11-03, Cash 109536.71760000002 Value 103828.11760000001\n",
      "2017-11-03, Close, 248.20\n",
      "rsi: 54.98522340364124\n",
      "2017-11-06, Cash 109536.71760000002 Value 103763.71760000002\n",
      "2017-11-06, Close, 251.00\n",
      "rsi: 60.22705607338392\n",
      "2017-11-07, Cash 109536.71760000002 Value 103708.51760000002\n",
      "2017-11-07, Close, 253.40\n",
      "rsi: 64.08729403773462\n",
      "2017-11-08, Cash 109536.71760000002 Value 103740.71760000002\n",
      "2017-11-08, Close, 252.00\n",
      "rsi: 60.404342706357795\n",
      "2017-11-09, Cash 109536.71760000002 Value 103717.71760000002\n",
      "2017-11-09, Close, 253.00\n",
      "rsi: 62.080605430524926\n",
      "2017-11-10, Cash 109536.71760000002 Value 103759.11760000001\n",
      "2017-11-10, Close, 251.20\n",
      "rsi: 57.3724066824616\n",
      "2017-11-13, Cash 109536.71760000002 Value 103625.71760000002\n",
      "2017-11-13, Close, 257.00\n",
      "rsi: 66.25352135600667\n",
      "2017-11-14, Cash 109536.71760000002 Value 103565.91760000002\n",
      "2017-11-14, Close, 259.60\n",
      "rsi: 69.33751871750701\n",
      "2017-11-15, Cash 109536.71760000002 Value 103653.31760000002\n",
      "2017-11-15, Close, 255.80\n",
      "rsi: 60.61818330221522\n",
      "2017-11-16, Cash 109536.71760000002 Value 103584.31760000002\n",
      "2017-11-16, Close, 258.80\n",
      "rsi: 64.42199509423892\n",
      "2017-11-17, Cash 109536.71760000002 Value 103561.31760000002\n",
      "2017-11-17, Close, 259.80\n",
      "rsi: 65.61423961485895\n",
      "2017-11-20, Cash 109536.71760000002 Value 103625.71760000002\n",
      "2017-11-20, Close, 257.00\n",
      "rsi: 59.592549213027745\n",
      "2017-11-21, Cash 109536.71760000002 Value 103694.71760000002\n",
      "2017-11-21, Close, 254.00\n",
      "rsi: 53.886349197642396\n",
      "2017-11-22, Cash 109536.71760000002 Value 103671.71760000002\n",
      "2017-11-22, Close, 255.00\n",
      "rsi: 55.418744290002664\n",
      "2017-11-23, Cash 109536.71760000002 Value 103694.71760000002\n",
      "2017-11-23, Close, 254.00\n",
      "rsi: 53.50399405093613\n",
      "2017-11-24, Cash 109536.71760000002 Value 103593.51760000002\n",
      "2017-11-24, Close, 258.40\n",
      "rsi: 60.04525111421275\n",
      "2017-11-27, Cash 109536.71760000002 Value 103694.71760000002\n",
      "2017-11-27, Close, 254.00\n",
      "rsi: 52.14496796464175\n",
      "2017-11-28, Cash 109536.71760000002 Value 103740.71760000002\n",
      "2017-11-28, Close, 252.00\n",
      "rsi: 48.9897373642993\n",
      "2017-11-29, Cash 109536.71760000002 Value 103933.91760000002\n",
      "2017-11-29, Close, 243.60\n",
      "rsi: 38.46296115513916\n",
      "2017-12-01, Cash 109536.71760000002 Value 103892.51760000002\n",
      "2017-12-01, Close, 245.40\n",
      "rsi: 41.37023751130815\n",
      "2017-12-04, Cash 109536.71760000002 Value 103984.51760000002\n",
      "2017-12-04, Close, 241.40\n",
      "rsi: 37.16790881655399\n",
      "2017-12-05, Cash 109536.71760000002 Value 103929.31760000002\n",
      "2017-12-05, Close, 243.80\n",
      "rsi: 41.03790757306808\n",
      "2017-12-06, Cash 109536.71760000002 Value 103947.71760000002\n",
      "2017-12-06, Close, 243.00\n",
      "rsi: 40.150178945726125\n",
      "2017-12-07, Cash 109536.71760000002 Value 103860.31760000002\n",
      "2017-12-07, Close, 246.80\n",
      "rsi: 46.113068474738384\n",
      "2017-12-08, Cash 109536.71760000002 Value 103814.31760000002\n",
      "2017-12-08, Close, 248.80\n",
      "rsi: 48.993455791481104\n",
      "2017-12-11, Cash 109536.71760000002 Value 103809.71760000002\n",
      "2017-12-11, Close, 249.00\n",
      "rsi: 49.28539014764926\n",
      "2017-12-12, Cash 109536.71760000002 Value 103800.51760000002\n",
      "2017-12-12, Close, 249.40\n",
      "rsi: 49.902959951774484\n",
      "2017-12-13, Cash 109536.71760000002 Value 103855.71760000002\n",
      "2017-12-13, Close, 247.00\n",
      "rsi: 46.26279731810389\n",
      "2017-12-14, Cash 109536.71760000002 Value 103924.71760000002\n",
      "2017-12-14, Close, 244.00\n",
      "rsi: 42.12621546653837\n",
      "2017-12-15, Cash 109536.71760000002 Value 103878.71760000002\n",
      "2017-12-15, Close, 246.00\n",
      "rsi: 45.617326876353715\n",
      "2017-12-18, Cash 109536.71760000002 Value 103800.51760000002\n",
      "2017-12-18, Close, 249.40\n",
      "rsi: 51.0258908941554\n",
      "2017-12-19, Cash 109536.71760000002 Value 103910.91760000002\n",
      "2017-12-19, Close, 244.60\n",
      "rsi: 44.32386568130932\n",
      "2017-12-20, Cash 109536.71760000002 Value 103929.31760000002\n",
      "2017-12-20, Close, 243.80\n",
      "rsi: 43.30300396159515\n",
      "2017-12-21, Cash 109536.71760000002 Value 103837.31760000002\n",
      "2017-12-21, Close, 247.80\n",
      "rsi: 49.55863091556102\n",
      "2017-12-22, Cash 109536.71760000002 Value 103855.71760000002\n",
      "2017-12-22, Close, 247.00\n",
      "rsi: 48.40824175560919\n",
      "2017-12-27, Cash 109536.71760000002 Value 103814.31760000002\n",
      "2017-12-27, Close, 248.80\n",
      "rsi: 51.155553091823805\n",
      "2017-12-28, Cash 109536.71760000002 Value 103694.71760000002\n",
      "2017-12-28, Close, 254.00\n",
      "rsi: 58.09752355979591\n",
      "2017-12-29, Cash 109536.71760000002 Value 103717.71760000002\n",
      "2017-12-29, Close, 253.00\n",
      "rsi: 56.436376702285465\n",
      "2018-01-03, Cash 109536.71760000002 Value 103662.51760000002\n",
      "2018-01-03, Close, 255.40\n",
      "rsi: 59.43420223700169\n",
      "2018-01-04, Cash 109536.71760000002 Value 103671.71760000002\n",
      "2018-01-04, Close, 255.00\n",
      "rsi: 58.7090637631206\n",
      "2018-01-05, Cash 109536.71760000002 Value 103671.71760000002\n",
      "2018-01-05, Close, 255.00\n",
      "rsi: 58.7090637631206\n",
      "2018-01-08, Cash 109536.71760000002 Value 103648.71760000002\n",
      "2018-01-08, Close, 256.00\n",
      "rsi: 60.119816915414454\n",
      "2018-01-09, Cash 109536.71760000002 Value 103653.31760000002\n",
      "2018-01-09, Close, 255.80\n",
      "rsi: 59.680635035091285\n",
      "2018-01-10, Cash 109536.71760000002 Value 103662.51760000002\n",
      "2018-01-10, Close, 255.40\n",
      "rsi: 58.756160711541895\n",
      "2018-01-11, Cash 109536.71760000002 Value 103671.71760000002\n",
      "2018-01-11, Close, 255.00\n",
      "rsi: 57.79207774498611\n",
      "2018-01-12, Cash 109536.71760000002 Value 103671.71760000002\n",
      "2018-01-12, Close, 255.00\n",
      "rsi: 57.79207774498611\n",
      "2018-01-15, Cash 109536.71760000002 Value 103469.31760000002\n",
      "2018-01-15, Close, 263.80\n",
      "rsi: 70.24786502842278\n",
      "2018-01-16, Cash 109536.71760000002 Value 103151.91760000002\n",
      "2018-01-16, Close, 277.60\n",
      "rsi: 80.14376369053414\n",
      "2018-01-17, Cash 109536.71760000002 Value 103151.91760000002\n",
      "2018-01-17, Close, 277.60\n",
      "rsi: 80.14376369053414\n",
      "2018-01-18, Cash 109536.71760000002 Value 103119.71760000002\n",
      "2018-01-18, Close, 279.00\n",
      "rsi: 80.89155558452251\n",
      "2018-01-19, Cash 109536.71760000002 Value 103096.71760000002\n",
      "2018-01-19, Close, 280.00\n",
      "rsi: 81.42953209611639\n",
      "2018-01-22, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-01-22, Close, 283.00\n",
      "rsi: 82.97784410702943\n",
      "2018-01-23, Cash 109536.71760000002 Value 103046.11760000001\n",
      "2018-01-23, Close, 282.20\n",
      "rsi: 81.0375160104461\n",
      "2018-01-24, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-01-24, Close, 282.00\n",
      "rsi: 80.53052733288567\n",
      "2018-01-25, Cash 109536.71760000002 Value 102797.71760000002\n",
      "2018-01-25, Close, 293.00\n",
      "rsi: 85.79452132930899\n",
      "2018-01-26, Cash 109536.71760000002 Value 102816.11760000001\n",
      "2018-01-26, Close, 292.20\n",
      "rsi: 84.01541398115566\n",
      "2018-01-29, Cash 109536.71760000002 Value 102972.51760000002\n",
      "2018-01-29, Close, 285.40\n",
      "rsi: 70.61175907850557\n",
      "2018-01-30, Cash 109536.71760000002 Value 103000.11760000001\n",
      "2018-01-30, Close, 284.20\n",
      "rsi: 68.53385059478407\n",
      "2018-01-31, Cash 109536.71760000002 Value 102986.31760000002\n",
      "2018-01-31, Close, 284.80\n",
      "rsi: 69.02466809785527\n",
      "2018-02-01, Cash 109536.71760000002 Value 102931.11760000001\n",
      "2018-02-01, Close, 287.20\n",
      "rsi: 70.97493612169116\n",
      "2018-02-02, Cash 109536.71760000002 Value 102774.71760000002\n",
      "2018-02-02, Close, 294.00\n",
      "rsi: 75.65245783905812\n",
      "2018-02-05, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-02-05, Close, 282.00\n",
      "rsi: 57.915020961314376\n",
      "2018-02-06, Cash 109536.71760000002 Value 102889.71760000002\n",
      "2018-02-06, Close, 289.00\n",
      "rsi: 63.317880959310216\n",
      "2018-02-07, Cash 109536.71760000002 Value 102793.11760000001\n",
      "2018-02-07, Close, 293.20\n",
      "rsi: 66.1276932403373\n",
      "2018-02-08, Cash 109536.71760000002 Value 102802.31760000002\n",
      "2018-02-08, Close, 292.80\n",
      "rsi: 65.61222367144528\n",
      "2018-02-09, Cash 109536.71760000002 Value 102820.71760000002\n",
      "2018-02-09, Close, 292.00\n",
      "rsi: 64.52882550123041\n",
      "2018-02-12, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-02-12, Close, 283.00\n",
      "rsi: 53.771739663191724\n",
      "2018-02-13, Cash 109536.71760000002 Value 103165.71760000002\n",
      "2018-02-13, Close, 277.00\n",
      "rsi: 48.02405272593965\n",
      "2018-02-14, Cash 109536.71760000002 Value 103142.71760000002\n",
      "2018-02-14, Close, 278.00\n",
      "rsi: 49.00246443246204\n",
      "2018-02-15, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-02-15, Close, 285.00\n",
      "rsi: 55.34000331677107\n",
      "2018-02-19, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-02-19, Close, 285.00\n",
      "rsi: 55.34000331677107\n",
      "2018-02-20, Cash 109536.71760000002 Value 102958.71760000002\n",
      "2018-02-20, Close, 286.00\n",
      "rsi: 56.24097351483955\n",
      "2018-02-21, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-02-21, Close, 282.00\n",
      "rsi: 51.74422785026382\n",
      "2018-02-22, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-02-22, Close, 282.00\n",
      "rsi: 51.74422785026382\n",
      "2018-02-23, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-02-23, Close, 282.00\n",
      "rsi: 51.74422785026382\n",
      "2018-02-26, Cash 109536.71760000002 Value 102820.71760000002\n",
      "2018-02-26, Close, 292.00\n",
      "rsi: 61.384711771252896\n",
      "2018-02-27, Cash 109536.71760000002 Value 102751.71760000002\n",
      "2018-02-27, Close, 295.00\n",
      "rsi: 63.725980100489785\n",
      "2018-02-28, Cash 109536.71760000002 Value 102673.51760000002\n",
      "2018-02-28, Close, 298.40\n",
      "rsi: 66.22532094259105\n",
      "2018-03-01, Cash 109536.71760000002 Value 102691.91760000002\n",
      "2018-03-01, Close, 297.60\n",
      "rsi: 65.08891734404287\n",
      "2018-03-02, Cash 109536.71760000002 Value 102682.71760000002\n",
      "2018-03-02, Close, 298.00\n",
      "rsi: 65.40853602793301\n",
      "2018-03-05, Cash 109536.71760000002 Value 102645.91760000002\n",
      "2018-03-05, Close, 299.60\n",
      "rsi: 66.72098951418428\n",
      "2018-03-06, Cash 109536.71760000002 Value 102668.91760000002\n",
      "2018-03-06, Close, 298.60\n",
      "rsi: 65.05952687561214\n",
      "2018-03-07, Cash 109536.71760000002 Value 102544.71760000002\n",
      "2018-03-07, Close, 304.00\n",
      "rsi: 69.47930940240653\n",
      "2018-03-08, Cash 109536.71760000002 Value 102751.71760000002\n",
      "2018-03-08, Close, 295.00\n",
      "rsi: 56.623431545859276\n",
      "2018-03-09, Cash 109536.71760000002 Value 102820.71760000002\n",
      "2018-03-09, Close, 292.00\n",
      "rsi: 53.09666344257336\n",
      "2018-03-12, Cash 109536.71760000002 Value 102742.51760000002\n",
      "2018-03-12, Close, 295.40\n",
      "rsi: 56.41031469103243\n",
      "2018-03-13, Cash 109536.71760000002 Value 102797.71760000002\n",
      "2018-03-13, Close, 293.00\n",
      "rsi: 53.535172833788785\n",
      "2018-03-14, Cash 109536.71760000002 Value 102903.51760000002\n",
      "2018-03-14, Close, 288.40\n",
      "rsi: 48.439179977138906\n",
      "2018-03-15, Cash 109536.71760000002 Value 103004.71760000002\n",
      "2018-03-15, Close, 284.00\n",
      "rsi: 44.11362463305306\n",
      "2018-03-16, Cash 109536.71760000002 Value 102512.51760000002\n",
      "2018-03-16, Close, 305.40\n",
      "rsi: 61.92313710773574\n",
      "2018-03-19, Cash 109536.71760000002 Value 102682.71760000002\n",
      "2018-03-19, Close, 298.00\n",
      "rsi: 55.354143318548466\n",
      "2018-03-20, Cash 109536.71760000002 Value 102958.71760000002\n",
      "2018-03-20, Close, 286.00\n",
      "rsi: 46.7021363890527\n",
      "2018-03-21, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-03-21, Close, 285.00\n",
      "rsi: 46.05609950055438\n",
      "2018-03-22, Cash 109536.71760000002 Value 102940.31760000002\n",
      "2018-03-22, Close, 286.80\n",
      "rsi: 47.46482994333422\n",
      "2018-03-23, Cash 109536.71760000002 Value 102912.71760000002\n",
      "2018-03-23, Close, 288.00\n",
      "rsi: 48.431686194566105\n",
      "2018-03-26, Cash 109536.71760000002 Value 102751.71760000002\n",
      "2018-03-26, Close, 295.00\n",
      "rsi: 53.77587665888385\n",
      "2018-03-27, Cash 109536.71760000002 Value 102765.51760000002\n",
      "2018-03-27, Close, 294.40\n",
      "rsi: 53.26632336677145\n",
      "2018-03-28, Cash 109536.71760000002 Value 102659.71760000002\n",
      "2018-03-28, Close, 299.00\n",
      "rsi: 56.65718806461459\n",
      "2018-04-02, Cash 109536.71760000002 Value 102636.71760000002\n",
      "2018-04-02, Close, 300.00\n",
      "rsi: 57.38113911266331\n",
      "2018-04-03, Cash 109536.71760000002 Value 102719.51760000002\n",
      "2018-04-03, Close, 296.40\n",
      "rsi: 53.89135617769286\n",
      "2018-04-04, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-04-04, Close, 285.00\n",
      "rsi: 44.63408617716165\n",
      "2018-04-05, Cash 109536.71760000002 Value 103096.71760000002\n",
      "2018-04-05, Close, 280.00\n",
      "rsi: 41.28443202891203\n",
      "2018-04-06, Cash 109536.71760000002 Value 103142.71760000002\n",
      "2018-04-06, Close, 278.00\n",
      "rsi: 39.99158652591464\n",
      "2018-04-10, Cash 109536.71760000002 Value 103004.71760000002\n",
      "2018-04-10, Close, 284.00\n",
      "rsi: 45.50502705456337\n",
      "2018-04-11, Cash 109536.71760000002 Value 102875.91760000002\n",
      "2018-04-11, Close, 289.60\n",
      "rsi: 50.112120819369615\n",
      "2018-04-12, Cash 109536.71760000002 Value 102636.71760000002\n",
      "2018-04-12, Close, 300.00\n",
      "rsi: 57.327351263428014\n",
      "2018-04-13, Cash 109536.71760000002 Value 102816.11760000001\n",
      "2018-04-13, Close, 292.20\n",
      "rsi: 51.3310770112194\n",
      "2018-04-16, Cash 109536.71760000002 Value 102829.91760000002\n",
      "2018-04-16, Close, 291.60\n",
      "rsi: 50.89012184662092\n",
      "2018-04-17, Cash 109536.71760000002 Value 102898.91760000002\n",
      "2018-04-17, Close, 288.60\n",
      "rsi: 48.640216518475484\n",
      "2018-04-18, Cash 109536.71760000002 Value 102770.11760000001\n",
      "2018-04-18, Close, 294.20\n",
      "rsi: 52.83227328266032\n",
      "2018-04-19, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-04-19, Close, 285.00\n",
      "rsi: 46.16562995716203\n",
      "2018-04-20, Cash 109536.71760000002 Value 102843.71760000002\n",
      "2018-04-20, Close, 291.00\n",
      "rsi: 50.54828590459059\n",
      "2018-04-23, Cash 109536.71760000002 Value 102774.71760000002\n",
      "2018-04-23, Close, 294.00\n",
      "rsi: 52.62502264459953\n",
      "2018-04-24, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-04-24, Close, 285.00\n",
      "rsi: 46.33802173121848\n",
      "2018-04-25, Cash 109536.71760000002 Value 103059.91760000002\n",
      "2018-04-25, Close, 281.60\n",
      "rsi: 44.19019974688824\n",
      "2018-04-26, Cash 109536.71760000002 Value 103096.71760000002\n",
      "2018-04-26, Close, 280.00\n",
      "rsi: 43.17598756321758\n",
      "2018-04-27, Cash 109536.71760000002 Value 103050.71760000002\n",
      "2018-04-27, Close, 282.00\n",
      "rsi: 44.87898791717722\n",
      "2018-04-30, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-04-30, Close, 285.00\n",
      "rsi: 47.42431569973589\n",
      "2018-05-02, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-05-02, Close, 283.00\n",
      "rsi: 45.90251954186336\n",
      "2018-05-03, Cash 109536.71760000002 Value 103211.71760000002\n",
      "2018-05-03, Close, 275.00\n",
      "rsi: 40.32800758788531\n",
      "2018-05-04, Cash 109536.71760000002 Value 103202.51760000002\n",
      "2018-05-04, Close, 275.40\n",
      "rsi: 40.71567996540034\n",
      "2018-05-07, Cash 109536.71760000002 Value 103119.71760000002\n",
      "2018-05-07, Close, 279.00\n",
      "rsi: 44.227571293158356\n",
      "2018-05-08, Cash 109536.71760000002 Value 103142.71760000002\n",
      "2018-05-08, Close, 278.00\n",
      "rsi: 43.45747000955855\n",
      "2018-05-09, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-05-09, Close, 283.00\n",
      "rsi: 48.30436201411184\n",
      "2018-05-10, Cash 109536.71760000002 Value 103101.31760000002\n",
      "2018-05-10, Close, 279.80\n",
      "rsi: 45.609666730058194\n",
      "2018-05-11, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-05-11, Close, 285.00\n",
      "rsi: 50.4472567803535\n",
      "2018-05-15, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-05-15, Close, 283.00\n",
      "rsi: 48.6548172091227\n",
      "2018-05-16, Cash 109536.71760000002 Value 102944.91760000002\n",
      "2018-05-16, Close, 286.60\n",
      "rsi: 51.963360163174876\n",
      "2018-05-17, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-05-17, Close, 285.00\n",
      "rsi: 50.408667823915955\n",
      "2018-05-18, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-05-18, Close, 285.00\n",
      "rsi: 50.408667823915955\n",
      "2018-05-21, Cash 109536.71760000002 Value 103096.71760000002\n",
      "2018-05-21, Close, 280.00\n",
      "rsi: 45.47736253074894\n",
      "2018-05-22, Cash 109536.71760000002 Value 103004.71760000002\n",
      "2018-05-22, Close, 284.00\n",
      "rsi: 49.71541393195231\n",
      "2018-05-23, Cash 109536.71760000002 Value 102935.71760000002\n",
      "2018-05-23, Close, 287.00\n",
      "rsi: 52.68588953525804\n",
      "2018-05-24, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-05-24, Close, 285.00\n",
      "rsi: 50.54230990687597\n",
      "2018-05-25, Cash 109536.71760000002 Value 103069.11760000001\n",
      "2018-05-25, Close, 281.20\n",
      "rsi: 46.65803439106125\n",
      "2018-05-28, Cash 109536.71760000002 Value 103087.51760000002\n",
      "2018-05-28, Close, 280.40\n",
      "rsi: 45.858990736040276\n",
      "2018-05-29, Cash 109536.71760000002 Value 103027.71760000002\n",
      "2018-05-29, Close, 283.00\n",
      "rsi: 48.9206541166733\n",
      "2018-05-30, Cash 109536.71760000002 Value 103096.71760000002\n",
      "2018-05-30, Close, 280.00\n",
      "rsi: 45.70874685381946\n",
      "2018-05-31, Cash 109536.71760000002 Value 103234.71760000002\n",
      "2018-05-31, Close, 274.00\n",
      "rsi: 40.045801035743644\n",
      "2018-06-01, Cash 109536.71760000002 Value 103009.31760000002\n",
      "2018-06-01, Close, 283.80\n",
      "rsi: 50.7733982016934\n",
      "2018-06-04, Cash 109536.71760000002 Value 103087.51760000002\n",
      "2018-06-04, Close, 280.40\n",
      "rsi: 47.59175072941715\n",
      "2018-06-05, Cash 109536.71760000002 Value 103092.11760000001\n",
      "2018-06-05, Close, 280.20\n",
      "rsi: 47.403575398592835\n",
      "2018-06-06, Cash 109536.71760000002 Value 103078.31760000002\n",
      "2018-06-06, Close, 280.80\n",
      "rsi: 48.066983082860986\n",
      "2018-06-07, Cash 109536.71760000002 Value 103036.91760000002\n",
      "2018-06-07, Close, 282.60\n",
      "rsi: 50.1004038013279\n",
      "2018-06-08, Cash 109536.71760000002 Value 103004.71760000002\n",
      "2018-06-08, Close, 284.00\n",
      "rsi: 51.684955062537036\n",
      "2018-06-11, Cash 109536.71760000002 Value 102981.71760000002\n",
      "2018-06-11, Close, 285.00\n",
      "rsi: 52.83699459469386\n",
      "2018-06-13, Cash 109536.71760000002 Value 103119.71760000002\n",
      "2018-06-13, Close, 279.00\n",
      "rsi: 45.78313999831389\n",
      "2018-06-14, Cash 109536.71760000002 Value 103115.11760000001\n",
      "2018-06-14, Close, 279.20\n",
      "rsi: 46.041728881855356\n",
      "2018-06-18, Cash 109536.71760000002 Value 103161.11760000001\n",
      "2018-06-18, Close, 277.20\n",
      "rsi: 43.79237063891983\n",
      "2018-06-19, Cash 109536.71760000002 Value 103004.71760000002\n",
      "2018-06-19, Close, 284.00\n",
      "rsi: 52.32130822771678\n",
      "2018-06-20, Cash 109536.71760000002 Value 103119.71760000002\n",
      "2018-06-20, Close, 279.00\n",
      "rsi: 46.70894810997121\n",
      "2018-06-21, Cash 109536.71760000002 Value 103326.71760000002\n",
      "2018-06-21, Close, 270.00\n",
      "rsi: 38.66848167045609\n",
      "2018-06-22, Cash 109536.71760000002 Value 103395.71760000002\n",
      "2018-06-22, Close, 267.00\n",
      "rsi: 36.418072244288744\n",
      "2018-06-25, Cash 109536.71760000002 Value 103363.51760000002\n",
      "2018-06-25, Close, 268.40\n",
      "rsi: 38.22487003420585\n",
      "2018-06-26, Cash 109536.71760000002 Value 103312.91760000002\n",
      "2018-06-26, Close, 270.60\n",
      "rsi: 41.05932955720323\n",
      "2018-06-27, Cash 109536.71760000002 Value 103303.71760000002\n",
      "2018-06-27, Close, 271.00\n",
      "rsi: 41.58414825463603\n",
      "2018-06-28, Cash 109536.71760000002 Value 103565.91760000002\n",
      "2018-06-28, Close, 259.60\n",
      "rsi: 32.65881899223045\n",
      "2018-06-29, Cash 109536.71760000002 Value 103487.71760000002\n",
      "2018-06-29, Close, 263.00\n",
      "rsi: 37.00175692747658\n",
      "2018-07-02, Cash 109536.71760000002 Value 103556.71760000002\n",
      "2018-07-02, Close, 260.00\n",
      "rsi: 34.86516473582313\n",
      "2018-07-03, Cash 109536.71760000002 Value 103556.71760000002\n",
      "2018-07-03, Close, 260.00\n",
      "rsi: 34.86516473582313\n",
      "2018-07-04, Cash 109536.71760000002 Value 103561.31760000002\n",
      "2018-07-04, Close, 259.80\n",
      "rsi: 34.710199419339716\n",
      "2018-07-05, Cash 109536.71760000002 Value 103694.71760000002\n",
      "2018-07-05, Close, 254.00\n",
      "rsi: 30.479319206268116\n",
      "2018-07-06, Cash 109536.71760000002 Value 103763.71760000002\n",
      "2018-07-06, Close, 251.00\n",
      "rsi: 28.541436894122967\n",
      "2018-07-06, BUY CREATE, 251.00\n",
      "2018-07-09, BUY EXECUTED, Price: 251.80, Cost: -1445.20, Comm 58.92\n",
      "2018-07-09, OPERATION PROFIT, GROSS -317.40, NET -384.99\n",
      "2018-07-09, Cash 99657.59640000002 Value 103577.59640000002\n",
      "2018-07-09, Close, 245.00\n",
      "rsi: 25.103686655203006\n",
      "2018-07-09, BUY CREATE, 245.00\n",
      "2018-07-10, BUY EXECUTED, Price: 245.20, Cost: 9808.00, Comm 58.85\n",
      "2018-07-10, Cash 89790.74840000003 Value 103566.74840000003\n",
      "2018-07-10, Close, 246.00\n",
      "rsi: 26.68859253921734\n",
      "2018-07-10, BUY CREATE, 246.00\n",
      "2018-07-11, BUY EXECUTED, Price: 246.00, Cost: 9840.00, Comm 59.04\n",
      "2018-07-11, Cash 79891.70840000003 Value 103622.90840000003\n",
      "2018-07-11, Close, 247.20\n",
      "rsi: 28.640069309536642\n",
      "2018-07-11, BUY CREATE, 247.20\n",
      "2018-07-12, BUY EXECUTED, Price: 249.00, Cost: 9960.00, Comm 59.76\n",
      "2018-07-12, Cash 69871.94840000004 Value 103844.74840000004\n",
      "2018-07-12, Close, 249.80\n",
      "rsi: 32.813114822492636\n",
      "2018-07-13, Cash 69871.94840000004 Value 104116.74840000004\n",
      "2018-07-13, Close, 251.80\n",
      "rsi: 35.91752643893038\n",
      "2018-07-16, Cash 69871.94840000004 Value 103708.74840000004\n",
      "2018-07-16, Close, 248.80\n",
      "rsi: 33.42285005674621\n",
      "2018-07-17, Cash 69871.94840000004 Value 104225.54840000003\n",
      "2018-07-17, Close, 252.60\n",
      "rsi: 39.18476944652042\n",
      "2018-07-18, Cash 69871.94840000004 Value 104443.14840000003\n",
      "2018-07-18, Close, 254.20\n",
      "rsi: 41.48122616867642\n",
      "2018-07-19, Cash 69871.94840000004 Value 104279.94840000004\n",
      "2018-07-19, Close, 253.00\n",
      "rsi: 40.25351648815034\n",
      "2018-07-20, Cash 69871.94840000004 Value 103871.94840000004\n",
      "2018-07-20, Close, 250.00\n",
      "rsi: 37.28269798831053\n",
      "2018-07-23, Cash 69871.94840000004 Value 103871.94840000004\n",
      "2018-07-23, Close, 250.00\n",
      "rsi: 37.28269798831053\n",
      "2018-07-24, Cash 69871.94840000004 Value 104007.94840000004\n",
      "2018-07-24, Close, 251.00\n",
      "rsi: 39.022461799952026\n",
      "2018-07-25, Cash 69871.94840000004 Value 104035.14840000003\n",
      "2018-07-25, Close, 251.20\n",
      "rsi: 39.384621752066806\n",
      "2018-07-26, Cash 69871.94840000004 Value 104715.14840000003\n",
      "2018-07-26, Close, 256.20\n",
      "rsi: 47.74097070944802\n",
      "2018-07-27, Cash 69871.94840000004 Value 106047.94840000004\n",
      "2018-07-27, Close, 266.00\n",
      "rsi: 59.52011565251278\n",
      "2018-07-30, Cash 69871.94840000004 Value 106047.94840000004\n",
      "2018-07-30, Close, 266.00\n",
      "rsi: 59.52011565251278\n",
      "2018-07-31, Cash 69871.94840000004 Value 106591.94840000004\n",
      "2018-07-31, Close, 270.00\n",
      "rsi: 63.422822249799715\n",
      "2018-08-01, Cash 69871.94840000004 Value 107870.34840000003\n",
      "2018-08-01, Close, 279.40\n",
      "rsi: 70.59698268877074\n",
      "2018-08-01, SELL CREATE, 279.40\n",
      "2018-08-02, SELL EXECUTED, Price: 279.00, Cost: 8656.53, Comm 58.59\n",
      "2018-08-02, Cash 79578.35840000004 Value 107454.35840000004\n",
      "2018-08-02, Close, 276.00\n",
      "rsi: 65.58616206101146\n",
      "2018-08-03, Cash 79578.35840000004 Value 107555.35840000004\n",
      "2018-08-03, Close, 277.00\n",
      "rsi: 66.3428312725369\n",
      "2018-08-06, Cash 79578.35840000004 Value 107858.35840000004\n",
      "2018-08-06, Close, 280.00\n",
      "rsi: 68.57513033625455\n",
      "2018-08-07, Cash 79578.35840000004 Value 106848.35840000004\n",
      "2018-08-07, Close, 270.00\n",
      "rsi: 55.38791144444376\n",
      "2018-08-08, Cash 79578.35840000004 Value 107535.15840000004\n",
      "2018-08-08, Close, 276.80\n",
      "rsi: 60.89489328915229\n",
      "2018-08-09, Cash 79578.35840000004 Value 106747.35840000004\n",
      "2018-08-09, Close, 269.00\n",
      "rsi: 52.837835463298674\n",
      "2018-08-10, Cash 79578.35840000004 Value 106545.35840000004\n",
      "2018-08-10, Close, 267.00\n",
      "rsi: 50.97542030173082\n",
      "2018-08-13, Cash 79578.35840000004 Value 106848.35840000004\n",
      "2018-08-13, Close, 270.00\n",
      "rsi: 53.61643919790798\n",
      "2018-08-14, Cash 79578.35840000004 Value 107191.75840000004\n",
      "2018-08-14, Close, 273.40\n",
      "rsi: 56.47803611616794\n",
      "2018-08-15, Cash 79578.35840000004 Value 107252.35840000004\n",
      "2018-08-15, Close, 274.00\n",
      "rsi: 56.982404117469315\n",
      "2018-08-16, Cash 79578.35840000004 Value 106525.15840000004\n",
      "2018-08-16, Close, 266.80\n",
      "rsi: 49.56012378238477\n",
      "2018-08-17, Cash 79578.35840000004 Value 106969.55840000004\n",
      "2018-08-17, Close, 271.20\n",
      "rsi: 53.54262667378367\n",
      "2018-08-20, Cash 79578.35840000004 Value 107151.35840000004\n",
      "2018-08-20, Close, 273.00\n",
      "rsi: 55.104304011861046\n",
      "2018-08-22, Cash 79578.35840000004 Value 108464.35840000004\n",
      "2018-08-22, Close, 286.00\n",
      "rsi: 64.40951277128632\n",
      "2018-08-23, Cash 79578.35840000004 Value 109171.35840000004\n",
      "2018-08-23, Close, 293.00\n",
      "rsi: 68.22810984790678\n",
      "2018-08-24, Cash 79578.35840000004 Value 108666.35840000004\n",
      "2018-08-24, Close, 288.00\n",
      "rsi: 63.026367605713666\n",
      "2018-08-28, Cash 79578.35840000004 Value 108888.55840000004\n",
      "2018-08-28, Close, 290.20\n",
      "rsi: 64.31551415845934\n",
      "2018-08-29, Cash 79578.35840000004 Value 108605.75840000004\n",
      "2018-08-29, Close, 287.40\n",
      "rsi: 61.38210924987061\n",
      "2018-08-30, Cash 79578.35840000004 Value 108464.35840000004\n",
      "2018-08-30, Close, 286.00\n",
      "rsi: 59.91075995730769\n",
      "2018-08-31, Cash 79578.35840000004 Value 108666.35840000004\n",
      "2018-08-31, Close, 288.00\n",
      "rsi: 61.336567880140144\n",
      "2018-09-03, Cash 79578.35840000004 Value 108060.35840000004\n",
      "2018-09-03, Close, 282.00\n",
      "rsi: 55.01505940646998\n",
      "2018-09-04, Cash 79578.35840000004 Value 108524.95840000005\n",
      "2018-09-04, Close, 286.60\n",
      "rsi: 58.54276887460818\n",
      "2018-09-05, Cash 79578.35840000004 Value 108363.35840000004\n",
      "2018-09-05, Close, 285.00\n",
      "rsi: 56.87216959399253\n",
      "2018-09-06, Cash 79578.35840000004 Value 107454.35840000004\n",
      "2018-09-06, Close, 276.00\n",
      "rsi: 48.489967391619\n",
      "2018-09-07, Cash 79578.35840000004 Value 107959.35840000004\n",
      "2018-09-07, Close, 281.00\n",
      "rsi: 52.664055058217215\n",
      "2018-09-10, Cash 79578.35840000004 Value 107696.75840000004\n",
      "2018-09-10, Close, 278.40\n",
      "rsi: 50.37793955248839\n",
      "2018-09-11, Cash 79578.35840000004 Value 107454.35840000004\n",
      "2018-09-11, Close, 276.00\n",
      "rsi: 48.2939332510872\n",
      "2018-09-12, Cash 79578.35840000004 Value 106747.35840000004\n",
      "2018-09-12, Close, 269.00\n",
      "rsi: 42.740407759521716\n",
      "2018-09-13, Cash 79578.35840000004 Value 107555.35840000004\n",
      "2018-09-13, Close, 277.00\n",
      "rsi: 49.83966983684196\n",
      "2018-09-14, Cash 79578.35840000004 Value 106747.35840000004\n",
      "2018-09-14, Close, 269.00\n",
      "rsi: 43.96889776005912\n",
      "2018-09-17, Cash 79578.35840000004 Value 107353.35840000004\n",
      "2018-09-17, Close, 275.00\n",
      "rsi: 48.836614358547756\n",
      "2018-09-18, Cash 79578.35840000004 Value 107050.35840000004\n",
      "2018-09-18, Close, 272.00\n",
      "rsi: 46.654179147727405\n",
      "2018-09-19, Cash 79578.35840000004 Value 106242.35840000004\n",
      "2018-09-19, Close, 264.00\n",
      "rsi: 41.34776365608433\n",
      "2018-09-20, Cash 79578.35840000004 Value 106949.35840000004\n",
      "2018-09-20, Close, 271.00\n",
      "rsi: 47.02544191484164\n",
      "2018-09-21, Cash 79578.35840000004 Value 107050.35840000004\n",
      "2018-09-21, Close, 272.00\n",
      "rsi: 47.8027981177714\n",
      "2018-09-24, Cash 79578.35840000004 Value 106949.35840000004\n",
      "2018-09-24, Close, 271.00\n",
      "rsi: 47.05912639222485\n",
      "2018-09-25, Cash 79578.35840000004 Value 106727.15840000004\n",
      "2018-09-25, Close, 268.80\n",
      "rsi: 45.38626573638468\n",
      "2018-09-26, Cash 79578.35840000004 Value 106464.55840000004\n",
      "2018-09-26, Close, 266.20\n",
      "rsi: 43.42173672476035\n",
      "2018-09-27, Cash 79578.35840000004 Value 105737.35840000004\n",
      "2018-09-27, Close, 259.00\n",
      "rsi: 38.45743528259799\n",
      "2018-09-28, Cash 79578.35840000004 Value 105535.35840000004\n",
      "2018-09-28, Close, 257.00\n",
      "rsi: 37.1856649504255\n",
      "2018-10-01, Cash 79578.35840000004 Value 105030.35840000004\n",
      "2018-10-01, Close, 252.00\n",
      "rsi: 34.145568183474566\n",
      "2018-10-02, Cash 79578.35840000004 Value 104828.35840000004\n",
      "2018-10-02, Close, 250.00\n",
      "rsi: 32.98396087204799\n",
      "2018-10-03, Cash 79578.35840000004 Value 105030.35840000004\n",
      "2018-10-03, Close, 252.00\n",
      "rsi: 35.35239924167253\n",
      "2018-10-04, Cash 79578.35840000004 Value 105030.35840000004\n",
      "2018-10-04, Close, 252.00\n",
      "rsi: 35.35239924167253\n",
      "2018-10-05, Cash 79578.35840000004 Value 104525.35840000004\n",
      "2018-10-05, Close, 247.00\n",
      "rsi: 32.06656845239766\n",
      "2018-10-08, Cash 79578.35840000004 Value 104121.35840000004\n",
      "2018-10-08, Close, 243.00\n",
      "rsi: 29.68918493723318\n",
      "2018-10-08, BUY CREATE, 243.00\n",
      "2018-10-09, BUY EXECUTED, Price: 243.20, Cost: 9971.20, Comm 59.83\n",
      "2018-10-09, Cash 69547.33120000004 Value 105388.13120000005\n",
      "2018-10-09, Close, 252.40\n",
      "rsi: 40.797309677820465\n",
      "2018-10-10, Cash 69547.33120000004 Value 105615.33120000004\n",
      "2018-10-10, Close, 254.00\n",
      "rsi: 42.46355317132975\n",
      "2018-10-11, Cash 69547.33120000004 Value 105615.33120000004\n",
      "2018-10-11, Close, 254.00\n",
      "rsi: 42.46355317132975\n",
      "2018-10-12, Cash 69547.33120000004 Value 106751.33120000004\n",
      "2018-10-12, Close, 262.00\n",
      "rsi: 50.536326555854245\n",
      "2018-10-15, Cash 69547.33120000004 Value 105047.33120000004\n",
      "2018-10-15, Close, 250.00\n",
      "rsi: 41.19865308381308\n",
      "2018-10-16, Cash 69547.33120000004 Value 105643.73120000005\n",
      "2018-10-16, Close, 254.20\n",
      "rsi: 45.02721339370196\n",
      "2018-10-17, Cash 69547.33120000004 Value 106268.53120000006\n",
      "2018-10-17, Close, 258.60\n",
      "rsi: 48.78904348121469\n",
      "2018-10-18, Cash 69547.33120000004 Value 106467.33120000004\n",
      "2018-10-18, Close, 260.00\n",
      "rsi: 49.962341783749565\n",
      "2018-10-19, Cash 69547.33120000004 Value 107177.33120000004\n",
      "2018-10-19, Close, 265.00\n",
      "rsi: 54.01455767156502\n",
      "2018-10-22, Cash 69547.33120000004 Value 108171.33120000004\n",
      "2018-10-22, Close, 272.00\n",
      "rsi: 59.01833440003518\n",
      "2018-10-23, Cash 69547.33120000004 Value 107603.33120000004\n",
      "2018-10-23, Close, 268.00\n",
      "rsi: 55.314407122277416\n",
      "2018-10-24, Cash 69547.33120000004 Value 107063.73120000005\n",
      "2018-10-24, Close, 264.20\n",
      "rsi: 51.97710245000457\n",
      "2018-10-25, Cash 69547.33120000004 Value 106751.33120000004\n",
      "2018-10-25, Close, 262.00\n",
      "rsi: 50.09277467176448\n",
      "2018-10-26, Cash 69547.33120000004 Value 107887.33120000004\n",
      "2018-10-26, Close, 270.00\n",
      "rsi: 56.2972509819482\n",
      "2018-10-29, Cash 69547.33120000004 Value 107887.33120000004\n",
      "2018-10-29, Close, 270.00\n",
      "rsi: 56.2972509819482\n",
      "2018-10-30, Cash 69547.33120000004 Value 107035.33120000004\n",
      "2018-10-30, Close, 264.00\n",
      "rsi: 50.8035342614948\n",
      "2018-10-31, Cash 69547.33120000004 Value 108739.33120000004\n",
      "2018-10-31, Close, 276.00\n",
      "rsi: 59.347849722443385\n",
      "2018-11-05, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-05, Close, 280.00\n",
      "rsi: 61.73359701432002\n",
      "2018-11-06, Cash 69547.33120000004 Value 109108.53120000006\n",
      "2018-11-06, Close, 278.60\n",
      "rsi: 60.39757640741702\n",
      "2018-11-07, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-07, Close, 280.00\n",
      "rsi: 61.29954685364349\n",
      "2018-11-08, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-08, Close, 280.00\n",
      "rsi: 61.29954685364349\n",
      "2018-11-09, Cash 69547.33120000004 Value 109023.33120000004\n",
      "2018-11-09, Close, 278.00\n",
      "rsi: 59.0705330413327\n",
      "2018-11-12, Cash 69547.33120000004 Value 108455.33120000004\n",
      "2018-11-12, Close, 274.00\n",
      "rsi: 54.780174512413865\n",
      "2018-11-13, Cash 69547.33120000004 Value 108284.93120000005\n",
      "2018-11-13, Close, 272.80\n",
      "rsi: 53.52420567178318\n",
      "2018-11-14, Cash 69547.33120000004 Value 109165.33120000004\n",
      "2018-11-14, Close, 279.00\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "rsi: 58.782364011659794\n",
      "2018-11-15, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-15, Close, 280.00\n",
      "rsi: 59.57674907601524\n",
      "2018-11-16, Cash 69547.33120000004 Value 109591.33120000004\n",
      "2018-11-16, Close, 282.00\n",
      "rsi: 61.18787715632502\n",
      "2018-11-19, Cash 69547.33120000004 Value 109591.33120000004\n",
      "2018-11-19, Close, 282.00\n",
      "rsi: 61.18787715632502\n",
      "2018-11-20, Cash 69547.33120000004 Value 109165.33120000004\n",
      "2018-11-20, Close, 279.00\n",
      "rsi: 57.22043494208389\n",
      "2018-11-21, Cash 69547.33120000004 Value 109591.33120000004\n",
      "2018-11-21, Close, 282.00\n",
      "rsi: 60.01267203384573\n",
      "2018-11-22, Cash 69547.33120000004 Value 110017.33120000004\n",
      "2018-11-22, Close, 285.00\n",
      "rsi: 62.63883131541318\n",
      "2018-11-23, Cash 69547.33120000004 Value 109733.33120000004\n",
      "2018-11-23, Close, 283.00\n",
      "rsi: 59.81832949968181\n",
      "2018-11-26, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-26, Close, 280.00\n",
      "rsi: 55.76231520596205\n",
      "2018-11-27, Cash 69547.33120000004 Value 109733.33120000004\n",
      "2018-11-27, Close, 283.00\n",
      "rsi: 58.77278243951265\n",
      "2018-11-28, Cash 69547.33120000004 Value 109307.33120000004\n",
      "2018-11-28, Close, 280.00\n",
      "rsi: 54.75962099005832\n",
      "2018-11-29, Cash 69547.33120000004 Value 109080.13120000003\n",
      "2018-11-29, Close, 278.40\n",
      "rsi: 52.693064652065445\n",
      "2018-12-03, Cash 69547.33120000004 Value 110272.93120000005\n",
      "2018-12-03, Close, 286.80\n",
      "rsi: 61.01190545267988\n",
      "2018-12-04, Cash 69547.33120000004 Value 110670.53120000006\n",
      "2018-12-04, Close, 289.60\n",
      "rsi: 63.32689537586097\n",
      "2018-12-05, Cash 69547.33120000004 Value 111295.33120000004\n",
      "2018-12-05, Close, 294.00\n",
      "rsi: 66.67547332141706\n",
      "2018-12-06, Cash 69547.33120000004 Value 111579.33120000004\n",
      "2018-12-06, Close, 296.00\n",
      "rsi: 68.10124024529411\n",
      "2018-12-07, Cash 69547.33120000004 Value 111437.33120000004\n",
      "2018-12-07, Close, 295.00\n",
      "rsi: 66.56767374230641\n",
      "2018-12-10, Cash 69547.33120000004 Value 110869.33120000004\n",
      "2018-12-10, Close, 291.00\n",
      "rsi: 60.68130852049086\n",
      "2018-12-11, Cash 69547.33120000004 Value 111721.33120000004\n",
      "2018-12-11, Close, 297.00\n",
      "rsi: 65.59572716152519\n",
      "2018-12-12, Cash 69547.33120000004 Value 111295.33120000004\n",
      "2018-12-12, Close, 294.00\n",
      "rsi: 61.45938915321556\n",
      "2018-12-13, Cash 69547.33120000004 Value 111380.53120000006\n",
      "2018-12-13, Close, 294.60\n",
      "rsi: 61.97582332132428\n",
      "2018-12-14, Cash 69547.33120000004 Value 111863.33120000004\n",
      "2018-12-14, Close, 298.00\n",
      "rsi: 64.85012598433293\n",
      "2018-12-17, Cash 69547.33120000004 Value 112147.33120000004\n",
      "2018-12-17, Close, 300.00\n",
      "rsi: 66.45639462322177\n",
      "2018-12-18, Cash 69547.33120000004 Value 112317.73120000005\n",
      "2018-12-18, Close, 301.20\n",
      "rsi: 67.41845432741094\n",
      "2018-12-19, Cash 69547.33120000004 Value 112857.33120000004\n",
      "2018-12-19, Close, 305.00\n",
      "rsi: 70.32130148998732\n",
      "2018-12-19, SELL CREATE, 305.00\n",
      "2018-12-20, SELL EXECUTED, Price: 305.60, Cost: 7876.39, Comm 58.68\n",
      "2018-12-20, Cash 79267.85600000004 Value 112597.85600000004\n",
      "2018-12-20, Close, 303.00\n",
      "rsi: 66.94084937808321\n",
      "2018-12-21, Cash 79267.85600000004 Value 112531.85600000004\n",
      "2018-12-21, Close, 302.40\n",
      "rsi: 65.91710402106918\n",
      "2018-12-26, Cash 79267.85600000004 Value 111387.85600000004\n",
      "2018-12-26, Close, 292.00\n",
      "rsi: 51.27841744570335\n",
      "2018-12-27, Cash 79267.85600000004 Value 111717.85600000004\n",
      "2018-12-27, Close, 295.00\n",
      "rsi: 54.4227245179349\n",
      "2018-12-28, Cash 79267.85600000004 Value 111365.85600000004\n",
      "2018-12-28, Close, 291.80\n",
      "rsi: 50.66661003356886\n",
      "Final Portfolio Value: 111365.86\n"
     ]
    },
    {
     "data": {
      "application/javascript": [
       "/* Put everything inside the global mpl namespace */\n",
       "window.mpl = {};\n",
       "\n",
       "\n",
       "mpl.get_websocket_type = function() {\n",
       "    if (typeof(WebSocket) !== 'undefined') {\n",
       "        return WebSocket;\n",
       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
       "        return MozWebSocket;\n",
       "    } else {\n",
       "        alert('Your browser does not have WebSocket support. ' +\n",
       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
       "              'Firefox 4 and 5 are also supported but you ' +\n",
       "              'have to enable WebSockets in about:config.');\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
       "    this.id = figure_id;\n",
       "\n",
       "    this.ws = websocket;\n",
       "\n",
       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
       "\n",
       "    if (!this.supports_binary) {\n",
       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
       "        if (warnings) {\n",
       "            warnings.style.display = 'block';\n",
       "            warnings.textContent = (\n",
       "                \"This browser does not support binary websocket messages. \" +\n",
       "                    \"Performance may be slow.\");\n",
       "        }\n",
       "    }\n",
       "\n",
       "    this.imageObj = new Image();\n",
       "\n",
       "    this.context = undefined;\n",
       "    this.message = undefined;\n",
       "    this.canvas = undefined;\n",
       "    this.rubberband_canvas = undefined;\n",
       "    this.rubberband_context = undefined;\n",
       "    this.format_dropdown = undefined;\n",
       "\n",
       "    this.image_mode = 'full';\n",
       "\n",
       "    this.root = $('<div/>');\n",
       "    this._root_extra_style(this.root)\n",
       "    this.root.attr('style', 'display: inline-block');\n",
       "\n",
       "    $(parent_element).append(this.root);\n",
       "\n",
       "    this._init_header(this);\n",
       "    this._init_canvas(this);\n",
       "    this._init_toolbar(this);\n",
       "\n",
       "    var fig = this;\n",
       "\n",
       "    this.waiting = false;\n",
       "\n",
       "    this.ws.onopen =  function () {\n",
       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
       "            fig.send_message(\"send_image_mode\", {});\n",
       "            if (mpl.ratio != 1) {\n",
       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
       "            }\n",
       "            fig.send_message(\"refresh\", {});\n",
       "        }\n",
       "\n",
       "    this.imageObj.onload = function() {\n",
       "            if (fig.image_mode == 'full') {\n",
       "                // Full images could contain transparency (where diff images\n",
       "                // almost always do), so we need to clear the canvas so that\n",
       "                // there is no ghosting.\n",
       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
       "            }\n",
       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
       "        };\n",
       "\n",
       "    this.imageObj.onunload = function() {\n",
       "        fig.ws.close();\n",
       "    }\n",
       "\n",
       "    this.ws.onmessage = this._make_on_message_function(this);\n",
       "\n",
       "    this.ondownload = ondownload;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_header = function() {\n",
       "    var titlebar = $(\n",
       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
       "        'ui-helper-clearfix\"/>');\n",
       "    var titletext = $(\n",
       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
       "        'text-align: center; padding: 3px;\"/>');\n",
       "    titlebar.append(titletext)\n",
       "    this.root.append(titlebar);\n",
       "    this.header = titletext[0];\n",
       "}\n",
       "\n",
       "\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_canvas = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var canvas_div = $('<div/>');\n",
       "\n",
       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
       "\n",
       "    function canvas_keyboard_event(event) {\n",
       "        return fig.key_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
       "    this.canvas_div = canvas_div\n",
       "    this._canvas_extra_style(canvas_div)\n",
       "    this.root.append(canvas_div);\n",
       "\n",
       "    var canvas = $('<canvas/>');\n",
       "    canvas.addClass('mpl-canvas');\n",
       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
       "\n",
       "    this.canvas = canvas[0];\n",
       "    this.context = canvas[0].getContext(\"2d\");\n",
       "\n",
       "    var backingStore = this.context.backingStorePixelRatio ||\n",
       "\tthis.context.webkitBackingStorePixelRatio ||\n",
       "\tthis.context.mozBackingStorePixelRatio ||\n",
       "\tthis.context.msBackingStorePixelRatio ||\n",
       "\tthis.context.oBackingStorePixelRatio ||\n",
       "\tthis.context.backingStorePixelRatio || 1;\n",
       "\n",
       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
       "\n",
       "    var rubberband = $('<canvas/>');\n",
       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
       "\n",
       "    var pass_mouse_events = true;\n",
       "\n",
       "    canvas_div.resizable({\n",
       "        start: function(event, ui) {\n",
       "            pass_mouse_events = false;\n",
       "        },\n",
       "        resize: function(event, ui) {\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "        stop: function(event, ui) {\n",
       "            pass_mouse_events = true;\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "    });\n",
       "\n",
       "    function mouse_event_fn(event) {\n",
       "        if (pass_mouse_events)\n",
       "            return fig.mouse_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
       "    // Throttle sequential mouse events to 1 every 20ms.\n",
       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
       "\n",
       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
       "\n",
       "    canvas_div.on(\"wheel\", function (event) {\n",
       "        event = event.originalEvent;\n",
       "        event['data'] = 'scroll'\n",
       "        if (event.deltaY < 0) {\n",
       "            event.step = 1;\n",
       "        } else {\n",
       "            event.step = -1;\n",
       "        }\n",
       "        mouse_event_fn(event);\n",
       "    });\n",
       "\n",
       "    canvas_div.append(canvas);\n",
       "    canvas_div.append(rubberband);\n",
       "\n",
       "    this.rubberband = rubberband;\n",
       "    this.rubberband_canvas = rubberband[0];\n",
       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
       "\n",
       "    this._resize_canvas = function(width, height) {\n",
       "        // Keep the size of the canvas, canvas container, and rubber band\n",
       "        // canvas in synch.\n",
       "        canvas_div.css('width', width)\n",
       "        canvas_div.css('height', height)\n",
       "\n",
       "        canvas.attr('width', width * mpl.ratio);\n",
       "        canvas.attr('height', height * mpl.ratio);\n",
       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
       "\n",
       "        rubberband.attr('width', width);\n",
       "        rubberband.attr('height', height);\n",
       "    }\n",
       "\n",
       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
       "    // upon first draw.\n",
       "    this._resize_canvas(600, 600);\n",
       "\n",
       "    // Disable right mouse context menu.\n",
       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
       "        return false;\n",
       "    });\n",
       "\n",
       "    function set_focus () {\n",
       "        canvas.focus();\n",
       "        canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    window.setTimeout(set_focus, 100);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>');\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) {\n",
       "            // put a spacer in here.\n",
       "            continue;\n",
       "        }\n",
       "        var button = $('<button/>');\n",
       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
       "                        'ui-button-icon-only');\n",
       "        button.attr('role', 'button');\n",
       "        button.attr('aria-disabled', 'false');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "\n",
       "        var icon_img = $('<span/>');\n",
       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
       "        icon_img.addClass(image);\n",
       "        icon_img.addClass('ui-corner-all');\n",
       "\n",
       "        var tooltip_span = $('<span/>');\n",
       "        tooltip_span.addClass('ui-button-text');\n",
       "        tooltip_span.html(tooltip);\n",
       "\n",
       "        button.append(icon_img);\n",
       "        button.append(tooltip_span);\n",
       "\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    var fmt_picker_span = $('<span/>');\n",
       "\n",
       "    var fmt_picker = $('<select/>');\n",
       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
       "    fmt_picker_span.append(fmt_picker);\n",
       "    nav_element.append(fmt_picker_span);\n",
       "    this.format_dropdown = fmt_picker[0];\n",
       "\n",
       "    for (var ind in mpl.extensions) {\n",
       "        var fmt = mpl.extensions[ind];\n",
       "        var option = $(\n",
       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
       "        fmt_picker.append(option);\n",
       "    }\n",
       "\n",
       "    // Add hover states to the ui-buttons\n",
       "    $( \".ui-button\" ).hover(\n",
       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
       "    );\n",
       "\n",
       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
       "    // which will in turn request a refresh of the image.\n",
       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_message = function(type, properties) {\n",
       "    properties['type'] = type;\n",
       "    properties['figure_id'] = this.id;\n",
       "    this.ws.send(JSON.stringify(properties));\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_draw_message = function() {\n",
       "    if (!this.waiting) {\n",
       "        this.waiting = true;\n",
       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
       "    }\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    var format_dropdown = fig.format_dropdown;\n",
       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
       "    fig.ondownload(fig, format);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
       "    var size = msg['size'];\n",
       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
       "        fig._resize_canvas(size[0], size[1]);\n",
       "        fig.send_message(\"refresh\", {});\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
       "    var x0 = msg['x0'] / mpl.ratio;\n",
       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
       "    var x1 = msg['x1'] / mpl.ratio;\n",
       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
       "    x0 = Math.floor(x0) + 0.5;\n",
       "    y0 = Math.floor(y0) + 0.5;\n",
       "    x1 = Math.floor(x1) + 0.5;\n",
       "    y1 = Math.floor(y1) + 0.5;\n",
       "    var min_x = Math.min(x0, x1);\n",
       "    var min_y = Math.min(y0, y1);\n",
       "    var width = Math.abs(x1 - x0);\n",
       "    var height = Math.abs(y1 - y0);\n",
       "\n",
       "    fig.rubberband_context.clearRect(\n",
       "        0, 0, fig.canvas.width / mpl.ratio, fig.canvas.height / mpl.ratio);\n",
       "\n",
       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
       "    // Updates the figure title.\n",
       "    fig.header.textContent = msg['label'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
       "    var cursor = msg['cursor'];\n",
       "    switch(cursor)\n",
       "    {\n",
       "    case 0:\n",
       "        cursor = 'pointer';\n",
       "        break;\n",
       "    case 1:\n",
       "        cursor = 'default';\n",
       "        break;\n",
       "    case 2:\n",
       "        cursor = 'crosshair';\n",
       "        break;\n",
       "    case 3:\n",
       "        cursor = 'move';\n",
       "        break;\n",
       "    }\n",
       "    fig.rubberband_canvas.style.cursor = cursor;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
       "    fig.message.textContent = msg['message'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
       "    // Request the server to send over a new figure.\n",
       "    fig.send_draw_message();\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
       "    fig.image_mode = msg['mode'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Called whenever the canvas gets updated.\n",
       "    this.send_message(\"ack\", {});\n",
       "}\n",
       "\n",
       "// A function to construct a web socket function for onmessage handling.\n",
       "// Called in the figure constructor.\n",
       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
       "    return function socket_on_message(evt) {\n",
       "        if (evt.data instanceof Blob) {\n",
       "            /* FIXME: We get \"Resource interpreted as Image but\n",
       "             * transferred with MIME type text/plain:\" errors on\n",
       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
       "             * to be part of the websocket stream */\n",
       "            evt.data.type = \"image/png\";\n",
       "\n",
       "            /* Free the memory for the previous frames */\n",
       "            if (fig.imageObj.src) {\n",
       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
       "                    fig.imageObj.src);\n",
       "            }\n",
       "\n",
       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
       "                evt.data);\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
       "            fig.imageObj.src = evt.data;\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        var msg = JSON.parse(evt.data);\n",
       "        var msg_type = msg['type'];\n",
       "\n",
       "        // Call the  \"handle_{type}\" callback, which takes\n",
       "        // the figure and JSON message as its only arguments.\n",
       "        try {\n",
       "            var callback = fig[\"handle_\" + msg_type];\n",
       "        } catch (e) {\n",
       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        if (callback) {\n",
       "            try {\n",
       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
       "                callback(fig, msg);\n",
       "            } catch (e) {\n",
       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
       "            }\n",
       "        }\n",
       "    };\n",
       "}\n",
       "\n",
       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
       "mpl.findpos = function(e) {\n",
       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
       "    var targ;\n",
       "    if (!e)\n",
       "        e = window.event;\n",
       "    if (e.target)\n",
       "        targ = e.target;\n",
       "    else if (e.srcElement)\n",
       "        targ = e.srcElement;\n",
       "    if (targ.nodeType == 3) // defeat Safari bug\n",
       "        targ = targ.parentNode;\n",
       "\n",
       "    // jQuery normalizes the pageX and pageY\n",
       "    // pageX,Y are the mouse positions relative to the document\n",
       "    // offset() returns the position of the element relative to the document\n",
       "    var x = e.pageX - $(targ).offset().left;\n",
       "    var y = e.pageY - $(targ).offset().top;\n",
       "\n",
       "    return {\"x\": x, \"y\": y};\n",
       "};\n",
       "\n",
       "/*\n",
       " * return a copy of an object with only non-object keys\n",
       " * we need this to avoid circular references\n",
       " * http://stackoverflow.com/a/24161582/3208463\n",
       " */\n",
       "function simpleKeys (original) {\n",
       "  return Object.keys(original).reduce(function (obj, key) {\n",
       "    if (typeof original[key] !== 'object')\n",
       "        obj[key] = original[key]\n",
       "    return obj;\n",
       "  }, {});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
       "    var canvas_pos = mpl.findpos(event)\n",
       "\n",
       "    if (name === 'button_press')\n",
       "    {\n",
       "        this.canvas.focus();\n",
       "        this.canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    var x = canvas_pos.x * mpl.ratio;\n",
       "    var y = canvas_pos.y * mpl.ratio;\n",
       "\n",
       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
       "                             step: event.step,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "\n",
       "    /* This prevents the web browser from automatically changing to\n",
       "     * the text insertion cursor when the button is pressed.  We want\n",
       "     * to control all of the cursor setting manually through the\n",
       "     * 'cursor' event from matplotlib */\n",
       "    event.preventDefault();\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    // Handle any extra behaviour associated with a key event\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.key_event = function(event, name) {\n",
       "\n",
       "    // Prevent repeat events\n",
       "    if (name == 'key_press')\n",
       "    {\n",
       "        if (event.which === this._key)\n",
       "            return;\n",
       "        else\n",
       "            this._key = event.which;\n",
       "    }\n",
       "    if (name == 'key_release')\n",
       "        this._key = null;\n",
       "\n",
       "    var value = '';\n",
       "    if (event.ctrlKey && event.which != 17)\n",
       "        value += \"ctrl+\";\n",
       "    if (event.altKey && event.which != 18)\n",
       "        value += \"alt+\";\n",
       "    if (event.shiftKey && event.which != 16)\n",
       "        value += \"shift+\";\n",
       "\n",
       "    value += 'k';\n",
       "    value += event.which.toString();\n",
       "\n",
       "    this._key_event_extra(event, name);\n",
       "\n",
       "    this.send_message(name, {key: value,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
       "    if (name == 'download') {\n",
       "        this.handle_save(this, null);\n",
       "    } else {\n",
       "        this.send_message(\"toolbar_button\", {name: name});\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
       "    this.message.textContent = tooltip;\n",
       "};\n",
       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
       "\n",
       "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n",
       "\n",
       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
       "    // object with the appropriate methods. Currently this is a non binary\n",
       "    // socket, so there is still some room for performance tuning.\n",
       "    var ws = {};\n",
       "\n",
       "    ws.close = function() {\n",
       "        comm.close()\n",
       "    };\n",
       "    ws.send = function(m) {\n",
       "        //console.log('sending', m);\n",
       "        comm.send(m);\n",
       "    };\n",
       "    // Register the callback with on_msg.\n",
       "    comm.on_msg(function(msg) {\n",
       "        //console.log('receiving', msg['content']['data'], msg);\n",
       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
       "        ws.onmessage(msg['content']['data'])\n",
       "    });\n",
       "    return ws;\n",
       "}\n",
       "\n",
       "mpl.mpl_figure_comm = function(comm, msg) {\n",
       "    // This is the function which gets called when the mpl process\n",
       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
       "\n",
       "    var id = msg.content.data.id;\n",
       "    // Get hold of the div created by the display call when the Comm\n",
       "    // socket was opened in Python.\n",
       "    var element = $(\"#\" + id);\n",
       "    var ws_proxy = comm_websocket_adapter(comm)\n",
       "\n",
       "    function ondownload(figure, format) {\n",
       "        window.open(figure.imageObj.src);\n",
       "    }\n",
       "\n",
       "    var fig = new mpl.figure(id, ws_proxy,\n",
       "                           ondownload,\n",
       "                           element.get(0));\n",
       "\n",
       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
       "    // web socket which is closed, not our websocket->open comm proxy.\n",
       "    ws_proxy.onopen();\n",
       "\n",
       "    fig.parent_element = element.get(0);\n",
       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
       "    if (!fig.cell_info) {\n",
       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
       "        return;\n",
       "    }\n",
       "\n",
       "    var output_index = fig.cell_info[2]\n",
       "    var cell = fig.cell_info[0];\n",
       "\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
       "    var width = fig.canvas.width/mpl.ratio\n",
       "    fig.root.unbind('remove')\n",
       "\n",
       "    // Update the output cell to use the data from the current canvas.\n",
       "    fig.push_to_output();\n",
       "    var dataURL = fig.canvas.toDataURL();\n",
       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
       "    // the notebook keyboard shortcuts fail.\n",
       "    IPython.keyboard_manager.enable()\n",
       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
       "    fig.close_ws(fig, msg);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
       "    fig.send_message('closing', msg);\n",
       "    // fig.ws.close()\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
       "    // Turn the data on the canvas into data in the output cell.\n",
       "    var width = this.canvas.width/mpl.ratio\n",
       "    var dataURL = this.canvas.toDataURL();\n",
       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Tell IPython that the notebook contents must change.\n",
       "    IPython.notebook.set_dirty(true);\n",
       "    this.send_message(\"ack\", {});\n",
       "    var fig = this;\n",
       "    // Wait a second, then push the new image to the DOM so\n",
       "    // that it is saved nicely (might be nice to debounce this).\n",
       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>');\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items){\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) { continue; };\n",
       "\n",
       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    // Add the status bar.\n",
       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "\n",
       "    // Add the close button to the window.\n",
       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
       "    buttongrp.append(button);\n",
       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
       "    titlebar.prepend(buttongrp);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(el){\n",
       "    var fig = this\n",
       "    el.on(\"remove\", function(){\n",
       "\tfig.close_ws(fig, {});\n",
       "    });\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
       "    // this is important to make the div 'focusable\n",
       "    el.attr('tabindex', 0)\n",
       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
       "    // off when our div gets focus\n",
       "\n",
       "    // location in version 3\n",
       "    if (IPython.notebook.keyboard_manager) {\n",
       "        IPython.notebook.keyboard_manager.register_events(el);\n",
       "    }\n",
       "    else {\n",
       "        // location in version 2\n",
       "        IPython.keyboard_manager.register_events(el);\n",
       "    }\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    var manager = IPython.notebook.keyboard_manager;\n",
       "    if (!manager)\n",
       "        manager = IPython.keyboard_manager;\n",
       "\n",
       "    // Check for shift+enter\n",
       "    if (event.shiftKey && event.which == 13) {\n",
       "        this.canvas_div.blur();\n",
       "        // select the cell after this one\n",
       "        var index = IPython.notebook.find_cell_index(this.cell_info[0]);\n",
       "        IPython.notebook.select(index + 1);\n",
       "    }\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    fig.ondownload(fig, null);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.find_output_cell = function(html_output) {\n",
       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
       "    // IPython event is triggered only after the cells have been serialised, which for\n",
       "    // our purposes (turning an active figure into a static one), is too late.\n",
       "    var cells = IPython.notebook.get_cells();\n",
       "    var ncells = cells.length;\n",
       "    for (var i=0; i<ncells; i++) {\n",
       "        var cell = cells[i];\n",
       "        if (cell.cell_type === 'code'){\n",
       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
       "                var data = cell.output_area.outputs[j];\n",
       "                if (data.data) {\n",
       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
       "                    data = data.data;\n",
       "                }\n",
       "                if (data['text/html'] == html_output) {\n",
       "                    return [cell, data, j];\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    }\n",
       "}\n",
       "\n",
       "// Register the function which deals with the matplotlib target/channel.\n",
       "// The kernel may be null if the page has been refreshed.\n",
       "if (IPython.notebook.kernel != null) {\n",
       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
       "}\n"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<img src=\"\" width=\"639.230792677615\">"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from __future__ import (absolute_import, division, print_function,\n",
    "                        unicode_literals)\n",
    "from pkg_resources import resource_filename\n",
    "import datetime\n",
    "import os.path\n",
    "import sys\n",
    "import backtrader as bt\n",
    "import backtrader.feeds as btfeed\n",
    "\n",
    "INIT_CASH = 100000\n",
    "RSI_PERIOD = 14\n",
    "COMMISSION_PER_TRANSACTION = 0.006\n",
    "RSI_UPPER = 70\n",
    "RSI_LOWER = 30\n",
    "DATA_FILE = resource_filename(__name__, \"../data/JFC_2010-01-01_2019-01-01_OHLCV.csv\")\n",
    "\n",
    "class RSIStrategy(bt.Strategy):\n",
    "    def log(self, txt, dt=None):\n",
    "        dt = dt or self.datas[0].datetime.date(0)\n",
    "        print('%s, %s' % (dt.isoformat(), txt))\n",
    "\n",
    "    def __init__(self):\n",
    "        self.dataclose = self.datas[0].close\n",
    "        self.order = None\n",
    "        self.buyprice = None\n",
    "        self.buycomm = None\n",
    "\n",
    "        self.rsi = bt.indicators.RelativeStrengthIndex(period=RSI_PERIOD)\n",
    "\n",
    "    def notify_order(self, order):\n",
    "        if order.status in [order.Submitted, order.Accepted]:\n",
    "            return\n",
    "\n",
    "        if order.status in [order.Completed]:\n",
    "            if order.isbuy():\n",
    "                self.log(\n",
    "                    'BUY EXECUTED, Price: %.2f, Cost: %.2f, Comm %.2f' %\n",
    "                    (order.executed.price,\n",
    "                     order.executed.value,\n",
    "                     order.executed.comm))\n",
    "\n",
    "                self.buyprice = order.executed.price\n",
    "                self.buycomm = order.executed.comm\n",
    "            else:  # Sell\n",
    "                self.log('SELL EXECUTED, Price: %.2f, Cost: %.2f, Comm %.2f' %\n",
    "                         (order.executed.price,\n",
    "                          order.executed.value,\n",
    "                          order.executed.comm))\n",
    "\n",
    "            self.bar_executed = len(self)\n",
    "\n",
    "        elif order.status in [order.Canceled, order.Margin, order.Rejected]:\n",
    "            self.log('Order Canceled/Margin/Rejected')\n",
    "\n",
    "        # Write down: no pending order\n",
    "        self.order = None\n",
    "\n",
    "    def notify_trade(self, trade):\n",
    "        if not trade.isclosed:\n",
    "            return\n",
    "\n",
    "        self.log('OPERATION PROFIT, GROSS %.2f, NET %.2f' %\n",
    "                 (trade.pnl, trade.pnlcomm))\n",
    "        \n",
    "    def notify_cashvalue(self, cash, value):\n",
    "        # Update cash and value every period\n",
    "        self.log('Cash %s Value %s' % (cash, value))\n",
    "        self.cash = cash\n",
    "        self.value = value\n",
    "\n",
    "    def next(self):\n",
    "        self.log('Close, %.2f' % self.dataclose[0])\n",
    "        print('rsi:', self.rsi[0])\n",
    "        if self.order:\n",
    "            return\n",
    "\n",
    "        # Only buy if there is enough cash for at least one stock\n",
    "        if self.cash >= self.dataclose[0]:\n",
    "            if (self.rsi[0] < RSI_LOWER):\n",
    "                self.log('BUY CREATE, %.2f' % self.dataclose[0])\n",
    "                # Take a 10% long position every time it's a buy signal (or whatever is afforder by the current cash position)\n",
    "                # \"size\" refers to the number of stocks to purchase\n",
    "                self.order = self.buy(size=int(min((INIT_CASH / self.dataclose[0]) * 0.1, self.cash / self.dataclose[0])))\n",
    "\n",
    "        # Only sell if you hold least one unit of the stock (and sell only that stock, so no short selling)\n",
    "        if (self.value - self.cash) > 0:\n",
    "            if (self.rsi[0] > RSI_UPPER):\n",
    "                self.log('SELL CREATE, %.2f' % self.dataclose[0])\n",
    "                # Sell a 5% sell position (or whatever is afforded by the current stock holding)\n",
    "                # \"size\" refers to the number of stocks to purchase\n",
    "                self.order = self.sell(size=int((INIT_CASH / self.dataclose[0]) * 0.1))\n",
    "\n",
    "\n",
    "if __name__ == '__main__':\n",
    "    cerebro = bt.Cerebro()\n",
    "    cerebro.addstrategy(RSIStrategy)\n",
    "    cerebro.broker.setcommission(commission=COMMISSION_PER_TRANSACTION)\n",
    "\n",
    "    data = btfeed.GenericCSVData(\n",
    "        dataname=DATA_FILE,\n",
    "\n",
    "        fromdate=datetime.datetime(2017, 1, 1),\n",
    "        todate=datetime.datetime(2019, 1, 1),\n",
    "\n",
    "        nullvalue=0.0,\n",
    "\n",
    "        dtformat=('%Y-%m-%d'),\n",
    "\n",
    "        datetime=0,\n",
    "        open=1,\n",
    "        high=2,\n",
    "        low=3,\n",
    "        close=4,\n",
    "        volume=5,\n",
    "        openinterest=-1\n",
    "    )\n",
    "    cerebro.adddata(data)\n",
    "    cerebro.broker.setcash(INIT_CASH)\n",
    "    print('Starting Portfolio Value: %.2f' % cerebro.broker.getvalue())\n",
    "    cerebro.run()\n",
    "    print('Final Portfolio Value: %.2f' % cerebro.broker.getvalue())\n",
    "    cerebro.plot(figsize=(30, 15))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.2"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
